Vue Composition API
up:: Vue The ‘Options API’ has been the default way of handling data in Vue 2. Vue 3 introduced the Composition API. It consolidates code that belongs together which was split up across multiple options (methods, computed, watchers).
The setup method
setup() changes the logic inside script. data, methods, computed and watch are merged into setup().
Reactivity
data() used to do the heavy lifting here.
- Vue Refs reactive (for single values)
- Vue reactive (for Objects)
Methods
Just write a function inside the setup() method. Then add it to the return object.