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

feat(props): 补充不同组件同名 props default 函数默认值互相影响测试例 #374

上级 eb04572b
<template>
<view class="component">
<text id="foo-arr">arr: {{arr}}</text>
</view>
</template>
<script>
export default {
props: {
arr: {
type: Array as PropType<number[]>,
default: () : Array<number> => {
return [1, 2, 3]
}
}
}
}
</script>
\ No newline at end of file
......@@ -17,18 +17,9 @@
<text>obj.count: </text>
<text class="object">{{obj.count}}</text>
</view>
<!-- <view class="row">-->
<!-- <text>obj.key: </text><text>{{obj.key}}</text>-->
<!-- </view>-->
<!-- <view class="row">-->
<!-- <text>date timestamp: </text><text>{{date.now()}}</text>-->
<!-- </view>-->
<!-- <view class="row">-->
<!-- <text>function result: </text><text>{{func()}}</text>-->
<!-- </view>-->
<!-- <view class="row">-->
<!-- <text>symbol: </text><text>{{symbol}}</text>-->
<!-- </view>-->
<view class="row">
<text id="check-type-arr">arr: {{arr}}</text>
</view>
</view>
</template>
......@@ -61,26 +52,12 @@
type: Object as PropType<CusomObject>,
default: () : CusomObject => ({ count: 0 } as CusomObject)
},
// date: {
// type: Date,
// default: () => {
// return new Date()
// }
// },
// func: {
// type: Function,
// default: () => {
// return () => {}
// }
// },
// symbol: {
// type: Symbol,
// default: Symbol('default')
// },
arr: {
type: Array as PropType<string[]>,
default: () : Array<string> => {
return ['a', 'b', 'c']
}
}
}
}
</script>
\ No newline at end of file
<style scoped>
</style>
\ No newline at end of file
......@@ -19,5 +19,10 @@ describe('$props', () => {
expect(await boolean.text()).toBe('true')
expect(await arrayString.text()).toBe('str1')
expect(await object.text()).toBe('1')
const checkTypeArr = await page.$('#check-type-arr')
expect((await checkTypeArr.text()).replaceAll('\n', '')).toBe('arr: ["a","b","c"]')
const fooArr = await page.$('#foo-arr')
expect((await fooArr.text()).replaceAll('\n', '')).toBe('arr: [1,2,3]')
})
})
<template>
<view class="page">
<check-type str="abcd" :num="12345" :bool="true" :obj="obj" :arrayString="arrayString"></check-type>
<!-- <view>简易类型</view>-->
<!-- <simple-->
<!-- str="abcd"-->
<!-- :num="12345"-->
<!-- :bool="true"-->
<!-- ></simple>-->
<Foo />
</view>
</template>
<script>
import checkType, { CusomObject } from "./check-type.uvue";
// import simple from "./simple.uvue";
import Foo from "./Foo.uvue";
export default {
components: {
checkType,
// simple
Foo
},
data() {
return {
......
<template>
<view class="component">
<view class="row">
<text>string: </text><text>{{str}}</text>
</view>
<view class="row">
<text>num: </text><text>{{num}}</text>
</view>
<view class="row">
<text>bool: </text><text>{{bool}}</text>
</view>
<!-- <view class="row">-->
<!-- <text>arr: </text>-->
<!-- [<text v-for="text in arr">{{text}},</text>]-->
<!-- </view>-->
<!-- <view class="row">-->
<!-- <text>obj.key: </text><text>{{obj.key}}</text>-->
<!-- </view>-->
<!-- <view class="row">-->
<!-- <text>obj.key: </text><text>{{obj.key}}</text>-->
<!-- </view>-->
<!-- <view class="row">-->
<!-- <text>date timestamp: </text><text>{{date.now()}}</text>-->
<!-- </view>-->
<!-- <view class="row">-->
<!-- <text>function result: </text><text>{{func()}}</text>-->
<!-- </view>-->
<!-- <view class="row">-->
<!-- <text>symbol: </text><text>{{symbol}}</text>-->
<!-- </view>-->
</view>
</template>
<script>
type IProps = {
str: string
}
export default {
props: ['str', 'num', 'bool'],
}
</script>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册