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

feat(composition api): isReadonly

上级 c63c8475
const PAGE_PATH = '/pages/composition-api/reactivity/is-readonly/is-readonly'
describe('isReadonly', () => {
if (process.env.uniTestPlatformInfo.startsWith('android')) {
let page = null
beforeAll(async () => {
page = await program.reLaunch(PAGE_PATH)
await page.waitFor('view')
})
it('basic', async () => {
const isReadonlyCount = await page.$('#is-readonly-count')
expect(await isReadonlyCount.text()).toBe('isReadonly(count): false')
const isReadonlyRefCount = await page.$('#is-readonly-ref-count')
expect(await isReadonlyRefCount.text()).toBe('isReadonly(refCount): false')
const isReadonlyReactiveCount = await page.$('#is-readonly-reactive-count')
expect(await isReadonlyReactiveCount.text()).toBe('isReadonly(reactiveCount): false')
const isReadonlyReadonlyCount = await page.$('#is-readonly-readonly-count')
expect(await isReadonlyReadonlyCount.text()).toBe('isReadonly(readonlyCount): true')
const isReadonlyShallowReactiveCount = await page.$('#is-readonly-shallow-reactive-count')
expect(await isReadonlyShallowReactiveCount.text()).toBe('isReadonly(shallowReactiveCount): false')
const isReadonlyShallowReadonlyCount = await page.$('#is-readonly-shallow-readonly-count')
expect(await isReadonlyShallowReadonlyCount.text()).toBe('isReadonly(shallowReadonlyCount): true')
})
} else {
it('other platform', () => {
expect(1).toBe(1)
})
}
})
\ No newline at end of file
<template><view class="page">isReadonly</view></template>
\ No newline at end of file
<template>
<view class="page">
<text id="is-readonly-count">isReadonly(count): {{ isProxyCount }}</text>
<text class="uni-common-mt" id="is-readonly-ref-count">isReadonly(refCount): {{ isProxyRefCount }}</text>
<text class="uni-common-mt" id="is-readonly-reactive-count">isReadonly(reactiveCount):
{{ isProxyReactiveCount }}</text>
<text class="uni-common-mt" id="is-readonly-readonly-count">isReadonly(readonlyCount):
{{ isProxyReadonlyCount }}</text>
<text class="uni-common-mt" id="is-readonly-shallow-reactive-count">isReadonly(shallowReactiveCount):
{{ isProxyShallowReactiveCount }}</text>
<text class="uni-common-mt" id="is-readonly-shallow-readonly-count">isReadonly(shallowReadonlyCount):
{{ isProxyShallowReadonlyCount }}</text>
</view>
</template>
<script setup>
const count = 0;
const isProxyCount = isReadonly(count);
const refCount = ref(0);
const isProxyRefCount = isReadonly(refCount);
const reactiveCount = reactive({ count: 0 });
const isProxyReactiveCount = isReadonly(reactiveCount);
const readonlyCount = readonly({ count: 0 });
const isProxyReadonlyCount = isReadonly(readonlyCount);
const shallowReactiveCount = shallowReactive({ count: 0 });
const isProxyShallowReactiveCount = isReadonly(shallowReactiveCount);
const shallowReadonlyCount = shallowReadonly({ count: 0 });
const isProxyShallowReadonlyCount = isReadonly(shallowReadonlyCount);
</script>
\ No newline at end of file
......@@ -161,7 +161,7 @@
{
name: 'isReadonly',
url: 'is-readonly',
enable: false,
enable: true,
},
{
name: 'shallowRef',
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册