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

refactor(reactivity): isProxy

上级 653a0093
......@@ -538,6 +538,11 @@ export default {
name: 'isReactive',
url: 'is-reactive/is-reactive'
},
{
id: 'is-readonly',
name: 'isReadonly',
url: 'is-readonly/is-readonly'
},
]
}
] as Page[]
......
<template>
<view class="page">
<view class="flex justify-between flex-row mb-10">
<text>isProxy(count):</text>
<text id="is-proxy-count">{{ isProxyCount }}</text>
</view>
<view class="flex justify-between flex-row mb-10">
<text>isProxy(count):</text>
<text id="is-proxy-count">{{ isProxyCount }}</text>
......
const PAGE_PATH = '/pages/composition-api/reactivity/is-readonly/is-readonly'
const PAGE_PATH = '/pages/reactivity/utilities/is-readonly/is-readonly'
describe('isReadonly', () => {
let page = null
......@@ -8,21 +8,21 @@ describe('isReadonly', () => {
})
it('basic', async () => {
const isReadonlyCount = await page.$('#is-readonly-count')
expect(await isReadonlyCount.text()).toBe('isReadonly(count): false')
expect(await isReadonlyCount.text()).toBe('false')
const isReadonlyRefCount = await page.$('#is-readonly-ref-count')
expect(await isReadonlyRefCount.text()).toBe('isReadonly(refCount): false')
expect(await isReadonlyRefCount.text()).toBe('false')
const isReadonlyReactiveCount = await page.$('#is-readonly-reactive-count')
expect(await isReadonlyReactiveCount.text()).toBe('isReadonly(reactiveCount): false')
expect(await isReadonlyReactiveCount.text()).toBe('false')
const isReadonlyReadonlyCount = await page.$('#is-readonly-readonly-count')
expect(await isReadonlyReadonlyCount.text()).toBe('isReadonly(readonlyCount): true')
expect(await isReadonlyReadonlyCount.text()).toBe('true')
const isReadonlyShallowReactiveCount = await page.$('#is-readonly-shallow-reactive-count')
expect(await isReadonlyShallowReactiveCount.text()).toBe('isReadonly(shallowReactiveCount): false')
expect(await isReadonlyShallowReactiveCount.text()).toBe('false')
const isReadonlyShallowReadonlyCount = await page.$('#is-readonly-shallow-readonly-count')
expect(await isReadonlyShallowReadonlyCount.text()).toBe('isReadonly(shallowReadonlyCount): true')
expect(await isReadonlyShallowReadonlyCount.text()).toBe('true')
})
})
\ No newline at end of file
<template>
<view class="page">
<text id="is-readonly-count">isReadonly(count): {{ isProxyCount }}</text>
<text class="mt-10" id="is-readonly-ref-count">isReadonly(refCount): {{ isProxyRefCount }}</text>
<text class="mt-10" id="is-readonly-reactive-count">isReadonly(reactiveCount):
{{ isProxyReactiveCount }}</text>
<text class="mt-10" id="is-readonly-readonly-count">isReadonly(readonlyCount):
{{ isProxyReadonlyCount }}</text>
<text class="mt-10" id="is-readonly-shallow-reactive-count">isReadonly(shallowReactiveCount):
{{ isProxyShallowReactiveCount }}</text>
<text class="mt-10" id="is-readonly-shallow-readonly-count">isReadonly(shallowReadonlyCount):
{{ isProxyShallowReadonlyCount }}</text>
<view class="flex justify-between flex-row mb-10">
<text>isReadonly(count):</text>
<text id="is-readonly-count">{{ isReadonlyCount }}</text>
</view>
<view class="flex justify-between flex-row mb-10">
<text>isReadonly(refCount):</text>
<text id="is-readonly-ref-count">{{ isReadonlyRefCount }}</text>
</view>
<view class="flex justify-between flex-row mb-10">
<text>isReadonly(reactiveCount):</text>
<text id="is-readonly-reactive-count">{{ isReadonlyReactiveCount }}</text>
</view>
<view class="flex justify-between flex-row mb-10">
<text>isReadonly(readonlyCount):</text>
<text id="is-readonly-readonly-count">{{ isReadonlyReadonlyCount }}</text>
</view>
<view class="flex justify-between flex-row mb-10">
<text>isReadonly(shallowReactiveCount):</text>
<text id="is-readonly-shallow-reactive-count">{{
isReadonlyShallowReactiveCount
}}</text>
</view>
<view class="flex justify-between flex-row mb-10">
<text>isReadonly(shallowReadonlyCount):</text>
<text id="is-readonly-shallow-readonly-count">{{
isReadonlyShallowReadonlyCount
}}</text>
</view>
</view>
</template>
<script setup>
<script setup lang='uts'>
const count = 0;
const isProxyCount = isReadonly(count);
const isReadonlyCount = isReadonly(count);
const refCount = ref(0);
const isProxyRefCount = isReadonly(refCount);
const isReadonlyRefCount = isReadonly(refCount);
const reactiveCount = reactive({ count: 0 });
const isProxyReactiveCount = isReadonly(reactiveCount);
const isReadonlyReactiveCount = isReadonly(reactiveCount);
const readonlyCount = readonly({ count: 0 });
const isProxyReadonlyCount = isReadonly(readonlyCount);
const isReadonlyReadonlyCount = isReadonly(readonlyCount);
const shallowReactiveCount = shallowReactive({ count: 0 });
const isProxyShallowReactiveCount = isReadonly(shallowReactiveCount);
const isReadonlyShallowReactiveCount = isReadonly(shallowReactiveCount);
const shallowReadonlyCount = shallowReadonly({ count: 0 });
const isProxyShallowReadonlyCount = isReadonly(shallowReadonlyCount);
const isReadonlyShallowReadonlyCount = isReadonly(shallowReadonlyCount);
</script>
\ No newline at end of file
......@@ -133,7 +133,7 @@ function transform(fileInfo, api) {
- [x] isProxy
- [x] isReactive
- [ ] isReadonly
- [x] isReadonly
- [ ] isRef
- [ ] toRef
- [ ] toRefs
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册
新手
引导
客服 返回
顶部