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

feat: 补充 props 数组字面量示例

上级 8bd78384
<template>
<view class="component">
<view class="row"><text>str: </text><text id="array-literal-str">{{ str }}</text></view>
<view class="row"><text>num: </text><text id="array-literal-num">{{ num }}</text></view>
<view class="row"><text>bool: </text><text id="array-literal-bool">{{ bool }}</text></view>
<view class="row"><text>obj: </text><text id="array-literal-obj">{{ obj }}</text></view>
<view class="row"><text>array: </text><text id="array-literal-arr">{{ arr }}</text></view>
</view>
</template>
<script>
export default {
props: ['str', 'num', 'bool', 'obj', 'arr'],
};
</script>
\ No newline at end of file
...@@ -8,6 +8,17 @@ describe('$props', () => { ...@@ -8,6 +8,17 @@ describe('$props', () => {
}) })
it('$props 属性生效', async () => { it('$props 属性生效', async () => {
const arrayLiteralStr = await page.$('#array-literal-str')
expect(await arrayLiteralStr.text()).toBe('abcd')
const arrayLiteralNum = await page.$('#array-literal-num')
expect(await arrayLiteralNum.text()).toBe('12345')
const arrayLiteralBool = await page.$('#array-literal-bool')
expect(await arrayLiteralBool.text()).toBe('true')
const arrayLiteralObj = await page.$('#array-literal-obj')
expect((await arrayLiteralObj.text()).replaceAll('\n', '').replaceAll(' ', '')).toBe('{"count":1}')
const arrayLiteralArr = await page.$('#array-literal-arr')
expect((await arrayLiteralArr.text()).replaceAll('\n', '')).toBe('[1,2,3]')
const string = await page.$('.string') const string = await page.$('.string')
const number = await page.$('.number') const number = await page.$('.number')
const boolean = await page.$('.boolean') const boolean = await page.$('.boolean')
......
<template> <template>
<view class="page"> <view class="page">
<array-literal str="abcd" :num="12345" :bool="true" :obj="obj" :arr="[1,2,3]" />
<check-type str="abcd" :num="12345" :bool="true" :obj="obj" :arrayString="arrayString"></check-type> <check-type str="abcd" :num="12345" :bool="true" :obj="obj" :arrayString="arrayString"></check-type>
<Foo /> <Foo />
</view> </view>
</template> </template>
<script> <script>
import ArrayLiteral from './array-literal.uvue'
import checkType, { CusomObject } from "./check-type.uvue"; import checkType, { CusomObject } from "./check-type.uvue";
import Foo from "./Foo.uvue"; import Foo from "./Foo.uvue";
export default { export default {
components: { components: {
ArrayLiteral,
checkType, checkType,
Foo Foo
}, },
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册