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

refactor(reactivity): isReactive

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