In vue demo3, why you are not using <script setup> ? Can you provide some examples ?
Best regards, Wilhem
Thanks a lot,
Best regards, Wilhem
Hi,
The script setup
syntax has some advantages over <script> with setup(), we will be slowly migrating to this syntax in our subsequent releases.
Since script setup
is compile-time syntactic sugar, it works the same as a setup()
function, you don't need to include return object to use your variables inside the component template.
Usage examples:
<script setup>
// variable
const msg = "Hello!"
// functions
function log() {
console.log(msg)
}
</script>
<template>
<button @click="log">{{ msg }}</button>
</template>
<script setup>
import MyComponent from "./MyComponent.vue"
</script>
<template>
<MyComponent />
</template>
<script setup>
const props = defineProps({
foo: String
})
const emit = defineEmits(["change", "delete"])
// setup code
</script>