提交 f20f7d00 编写于 作者: DCloud-WZF's avatar DCloud-WZF 💬

feat(props): 补充 withDefaults 示例

上级 0617465b
......@@ -3,6 +3,7 @@
<array-literal :str="str" :num="num" :bool="bool" :obj="obj" :arr="arr" />
<object-type str="str" :num="num" :bool="bool" :obj="obj" :arr="arr" />
<same-name-prop-default-value />
<props-with-defaults />
</view>
</template>
......@@ -10,6 +11,7 @@
import ArrayLiteral from './array-literal-composition.uvue'
import ObjectType from "./object-type-composition.uvue";
import SameNamePropDefaultValue from "./same-name-prop-default-value-composition.uvue";
import PropsWithDefaults from "./props-with-defaults.uvue";
const str = 'str'
const num = 10
......
......@@ -3,6 +3,7 @@
<array-literal :str="str" :num="num" :bool="bool" :obj="obj" :arr="arr" />
<object-type str="str" :num="num" :bool="bool" :obj="obj" :arr="arr" />
<same-name-prop-default-value />
<props-with-defaults />
</view>
</template>
......@@ -10,12 +11,14 @@
import ArrayLiteral from './array-literal-options.uvue'
import ObjectType from "./object-type-options.uvue";
import SameNamePropDefaultValue from "./same-name-prop-default-value-options.uvue";
import PropsWithDefaults from "./props-with-defaults.uvue";
export default {
components: {
ArrayLiteral,
ObjectType,
SameNamePropDefaultValue
SameNamePropDefaultValue,
PropsWithDefaults
},
data() {
return {
......
<template>
<view class='mt-10'>
<text class="mb-10 bold">withDefaults</text>
<view class="mb-10 flex flex-row justify-between">
<text>msg</text>
<text>{{ props.msg }}</text>
</view>
<view class="mb-10 flex flex-row justify-between">
<text>labels</text>
<text>{{ JSON.stringify(props.labels) }}</text>
</view>
</view>
</template>
<script setup lang="uts">
interface CustomProps {
msg: string
labels : string[]
}
const props = withDefaults(defineProps<CustomProps>(), {
msg: 'hello',
labels: ():string[] => ['a', 'b']
})
</script>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册