i find "<script setup>" in vue js a little confusing. Normally, for xml-like syntax, you…
- User
i find "" in vue js a little confusing. Normally, for xml-like syntax, you only have one tag name and attributes that use "=" to set up key-value pairs. "" seems violating the normal rule.
- Assistant
The
<script setup>syntax you are referring to is specific to Vue 3's Composition API. It's not a violation of the normal rule for XML-like syntax as it is not an HTML or XML tag. Instead, it's a Vue-specific directive that allows developers to write a<script>block in a more declarative and compact way.In a Vue component file (a
.vuefile), you normally have three sections:- — This is where you write the HTML-like syntax for your template.