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().


data() used to do the heavy lifting here.


Just write a function inside the setup() method. Then add it to the return object.