Skip to content

建议:建议在基础分类-响应式基础中添加对 <script setup>的对比说明 #3246

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
HBolck opened this issue Jun 6, 2025 · 0 comments

Comments

@HBolck
Copy link

HBolck commented Jun 6, 2025

https://cn.vuejs.org/guide/essentials/reactivity-fundamentals#script-setup

现状:缺少对选项式的用法示例。

建议在这个位置添加选项式用法示例和组合式的用法示例。
这样新手在阅读文档的时候,可以通过两种方式对比理解<script setup>的优势和原理,有助于更好理解框架本身的意图。
建议使用下面的方式列举出优缺点。

下面的内容来自Deepseek生成

传统写法痛点 <script setup> 解决方案
需手动返回模板使用的变量 顶层变量自动暴露
组件需在 components 注册 导入即自动注册
props/emits 声明分离 使用 defineProps/defineEmits 集中声明
逻辑关注点分散在多个选项 所有代码按功能组织(非选项分割)
this 上下文问题 无 this,纯函数式编程
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant