Vue 能否内置在 setup 语法糖设置 name ?Can Vue set name in the setup syntax?
What problem does this feature solve?
Chinese
一些第三方 vite
插件 unplugin-vue-setup-extend-plus 实现了功能,但一直会出现一些不可预期的错误。在使用 script setup
语法糖的时候,如果再新建一个 script
来设置组件的 name
不免有些冗余和麻烦,所以建议 vue
内置此功能
例:
<script lang="ts" setup name="MyComponent">
// code...
</script>
English
Some third-party vite
plug-ins, such as unplugin-vue-setup-extend-plus, have implemented functions, but there have been some unexpected errors. When using script setup
syntax sugar, if you create a new script
to set the name
of the component, it will inevitably be redundant and troublesome, so it is recommended that this function be built into Vue
Example:
<script lang="ts" setup name="MyComponent">
// code...
</script>
What does the proposed API look like?
<script lang="ts" setup name="MyComponent">
// code...
</script>
那样可以实现递归组件吗? @AlanSean
https://staging-cn.vuejs.org/api/sfc-script-setup.html#recursive-components