Vue Props 声明:修订历史

跳到导航 跳到搜索

差异选择:选中要对比的版本的单选按钮,按Enter键或下方的按钮。
说明:(当前)=与最后版本之间的差异,(之前)=与上一版本之间的差异,=小编辑。

2024年1月30日 (星期二)

  • 当前之前 09:322024年1月30日 (二) 09:32BrainBs 讨论 贡献 799字节 +1 无编辑摘要
  • 当前之前 09:302024年1月30日 (二) 09:30BrainBs 讨论 贡献 798字节 +798 创建页面,内容为“ 一个组件需要显式声明它所接受的 props,这样 Vue 才能知道外部传入的哪些是 props,哪些是透传 attribute 。 在使用 <script setup> 的单文件组件中,props 可以使用 defineProps() 宏来声明: ```vue <script setup> const props = defineProps(['foo']) console.log(props.foo) </script></pre> 除了使用字符串数组来声明 prop 外,还可以使用对象的形式: <syntaxhighlight lang="js"…”