JavaScript/vue.js/defineProps:修订间差异

来自康健生活
Kangkk​(留言 | 贡献)
创建页面,内容为“== 默认值 == vue 3.5.0+ 响应式 Props 解构 <syntaxhighlight lang="typescript"> const { type = 'number', useColor = false, usePrefix = false, value, title = '', color = '#ffffffff', } = defineProps({ type: String as PropType<'number' | 'string'>, useColor: Boolean, usePrefix: Boolean, value: [Number, String] as PropType<number | string>, title: String, color: [String, undefined] as PropType<ColorInputWithoutInstance>, }) </syntaxh…”
 
Kangkk​(留言 | 贡献)
 
第1行: 第1行:
== 默认值 ==
== 默认值 ==
vue 3.5.0+ 响应式 Props 解构
vue 3.5.0+ [https://cn.vuejs.org/guide/components/props.html#reactive-props-destructure 响应式 Props 解构]


<syntaxhighlight lang="typescript">
<syntaxhighlight lang="typescript">
第20行: 第20行:
</syntaxhighlight>
</syntaxhighlight>


vue 3.4.0- 使用 withDefaults 提供默认值
vue 3.4.0- 使用 [https://cn.vuejs.org/api/sfc-script-setup#default-props-values-when-using-type-declaration withDefaults] 提供默认值


<syntaxhighlight lang="typescript">
<syntaxhighlight lang="typescript">