What I want to share today is a RFC that will bring even more love for Vue from React world. What is script setup ? What are we talking about here ? We talk about a compile step for script tag to improve the authoring experience when using the Composition API inside Single File Components.
Let’s say we have this component:.
As you can see we have our count ref and we export it to the template by return it in the setup() method. This is pretty clear when you have few exports or one function but when the component becomes bigger and you have 10 exports or more that return becomes BIG 🤯 pretty fast.
- This is where script setup can help, you don’t need to return anything or use setup function.
The code looks much cleaner and nice. Isn’t that a piece of beauty ?
Just export what you use in template using export keyword and you are done.