Skip to content

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

@HBolck

Description

@HBolck

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

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

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

下面的内容来自Deepseek生成

传统写法痛点 <script setup> 解决方案
需手动返回模板使用的变量 顶层变量自动暴露
组件需在 components 注册 导入即自动注册
props/emits 声明分离 使用 defineProps/defineEmits 集中声明
逻辑关注点分散在多个选项 所有代码按功能组织(非选项分割)
this 上下文问题 无 this,纯函数式编程

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions