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

feat(composition api): isReactive

上级 13dc0caa
const PAGE_PATH = '/pages/composition-api/reactivity/is-reactive/is-reactive'
describe('isReactive', () => {
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 isReactiveCount = await page.$('#is-reactive-count')
expect(await isReactiveCount.text()).toBe('isReactive(count): false')
const isReactiveRefCount = await page.$('#is-reactive-ref-count')
expect(await isReactiveRefCount.text()).toBe('isReactive(refCount): false')
const isReactiveReactiveCount = await page.$('#is-reactive-reactive-count')
expect(await isReactiveReactiveCount.text()).toBe('isReactive(reactiveCount): true')
const isReactiveReadonlyCount = await page.$('#is-reactive-readonly-count')
expect(await isReactiveReadonlyCount.text()).toBe('isReactive(readonlyCount): false')
const isReactiveShallowReactiveCount = await page.$('#is-reactive-shallow-reactive-count')
expect(await isReactiveShallowReactiveCount.text()).toBe('isReactive(shallowReactiveCount): true')
const isReactiveShallowReadonlyCount = await page.$('#is-reactive-shallow-readonly-count')
expect(await isReactiveShallowReadonlyCount.text()).toBe('isReactive(shallowReadonlyCount): false')
})
} else {
it('other platform', () => {
expect(1).toBe(1)
})
}
})
\ No newline at end of file
<template><view class="page">isReactive</view></template>
\ No newline at end of file
<template>
<view class="page">
<text id="is-reactive-count">isReactive(count): {{ isProxyCount }}</text>
<text class="uni-common-mt" id="is-reactive-ref-count">isReactive(refCount): {{ isProxyRefCount }}</text>
<text class="uni-common-mt" id="is-reactive-reactive-count">isReactive(reactiveCount):
{{ isProxyReactiveCount }}</text>
<text class="uni-common-mt" id="is-reactive-readonly-count">isReactive(readonlyCount):
{{ isProxyReadonlyCount }}</text>
<text class="uni-common-mt" id="is-reactive-shallow-reactive-count">isReactive(shallowReactiveCount):
{{ isProxyShallowReactiveCount }}</text>
<text class="uni-common-mt" id="is-reactive-shallow-readonly-count">isReactive(shallowReadonlyCount):
{{ isProxyShallowReadonlyCount }}</text>
</view>
</template>
<script setup>
const count = 0;
const isProxyCount = isReactive(count);
const refCount = ref(0);
const isProxyRefCount = isReactive(refCount);
const reactiveCount = reactive({ count: 0 });
const isProxyReactiveCount = isReactive(reactiveCount);
const readonlyCount = readonly({ count: 0 });
const isProxyReadonlyCount = isReactive(readonlyCount);
const shallowReactiveCount = shallowReactive({ count: 0 });
const isProxyShallowReactiveCount = isReactive(shallowReactiveCount);
const shallowReadonlyCount = shallowReadonly({ count: 0 });
const isProxyShallowReadonlyCount = isReactive(shallowReadonlyCount);
</script>
\ No newline at end of file
......@@ -156,7 +156,7 @@
{
name: 'isReactive',
url: 'is-reactive',
enable: false,
enable: true,
},
{
name: 'isReadonly',
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册