Questions tagged [vue-script-setup]

is a compile-time syntactic sugar for using Composition API inside Single-File Components (SFCs). It is the recommended syntax if you are using both SFCs and Composition API.

It provides a number of advantages over the normal <script> syntax

  1. More succinct code with less boilerplate
  2. Ability to declare props and emitted events using pure TypeScript
  3. Better runtime performance (the template is compiled into a render function in the same scope, without an intermediate proxy)
  4. Better IDE type-inference performance (less work for the language server to extract types from code)

For more details check the official docs

162 questions
90
votes
8 answers

How to use props in How to do that in
Artur Müller Romanov
  • 4,417
  • 10
  • 73
  • 132

10
votes
1 answer

Vue3 using script setup, how to access this.$router.push()

I am new to Vue3 and am struggling with some examples. I have a simple login component that should redirect to another page but isn't. Here is my template: And here is my script: The problem is that the this.$router is not available, because this…
Josh Davidson
  • 147
  • 1
  • 1
  • 5
10
votes
2 answers

Vue