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

refactor(reactivity): isProxy

上级 9e44579e
......@@ -523,6 +523,17 @@ export default {
url: 'watch-sync-effect/watch-sync-effect'
},
]
},
{
id: 'utilities',
name: '工具',
children: [
{
id: 'is-proxy',
name: 'isProxy',
url: 'is-proxy/is-proxy'
},
]
}
] as Page[]
},
......
const PAGE_PATH = '/pages/composition-api/reactivity/is-proxy/is-proxy'
const PAGE_PATH = '/pages/reactivity/utilities/is-proxy/is-proxy'
describe('isProxy', () => {
let page = null
beforeAll(async () => {
page = await program.reLaunch(PAGE_PATH)
await page.waitFor('view')
})
it('basic', async () => {
const isProxyCount = await page.$('#is-proxy-count')
expect(await isProxyCount.text()).toBe('isProxy(count): false')
expect(await isProxyCount.text()).toBe('false')
const isProxyRefCount = await page.$('#is-proxy-ref-count')
expect(await isProxyRefCount.text()).toBe('isProxy(refCount): false')
expect(await isProxyRefCount.text()).toBe('false')
const isProxyReactiveCount = await page.$('#is-proxy-reactive-count')
expect(await isProxyReactiveCount.text()).toBe('isProxy(reactiveCount): true')
expect(await isProxyReactiveCount.text()).toBe('true')
const isProxyReadonlyCount = await page.$('#is-proxy-readonly-count')
expect(await isProxyReadonlyCount.text()).toBe('isProxy(readonlyCount): true')
expect(await isProxyReadonlyCount.text()).toBe('true')
const isProxyShallowReactiveCount = await page.$('#is-proxy-shallow-reactive-count')
expect(await isProxyShallowReactiveCount.text()).toBe('isProxy(shallowReactiveCount): true')
expect(await isProxyShallowReactiveCount.text()).toBe('true')
const isProxyShallowReadonlyCount = await page.$('#is-proxy-shallow-readonly-count')
expect(await isProxyShallowReadonlyCount.text()).toBe('isProxy(shallowReadonlyCount): true')
expect(await isProxyShallowReadonlyCount.text()).toBe('true')
})
})
\ No newline at end of file
<template>
<view class="page">
<text id="is-proxy-count">isProxy(count): {{ isProxyCount }}</text>
<text class="mt-10" id="is-proxy-ref-count">isProxy(refCount): {{ isProxyRefCount }}</text>
<text class="mt-10" id="is-proxy-reactive-count">isProxy(reactiveCount): {{ isProxyReactiveCount }}</text>
<text class="mt-10" id="is-proxy-readonly-count">isProxy(readonlyCount): {{ isProxyReadonlyCount }}</text>
<text class="mt-10" id="is-proxy-shallow-reactive-count">isProxy(shallowReactiveCount): {{ isProxyShallowReactiveCount }}</text>
<text class="mt-10" id="is-proxy-shallow-readonly-count">isProxy(shallowReadonlyCount): {{ isProxyShallowReadonlyCount }}</text>
<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>
</view>
<view class="flex justify-between flex-row mb-10">
<text>isProxy(refCount):</text>
<text id="is-proxy-ref-count">{{ isProxyRefCount }}</text>
</view>
<view class="flex justify-between flex-row mb-10">
<text>isProxy(reactiveCount):</text>
<text id="is-proxy-reactive-count">{{ isProxyReactiveCount }}</text>
</view>
<view class="flex justify-between flex-row mb-10">
<text>isProxy(readonlyCount):</text>
<text id="is-proxy-readonly-count">{{ isProxyReadonlyCount }}</text>
</view>
<view class="flex justify-between flex-row mb-10">
<text>isProxy(shallowReactiveCount):</text>
<text id="is-proxy-shallow-reactive-count">{{
isProxyShallowReactiveCount
}}</text>
</view>
<view class="flex justify-between flex-row mb-10">
<text>isProxy(shallowReadonlyCount):</text>
<text id="is-proxy-shallow-readonly-count">{{
isProxyShallowReadonlyCount
}}</text>
</view>
</view>
</template>
<script setup>
const count = 0;
const isProxyCount = isProxy(count);
<script setup lang="uts">
const count = 0;
const isProxyCount = isProxy(count);
const refCount = ref(0);
const isProxyRefCount = isProxy(refCount);
const refCount = ref(0);
const isProxyRefCount = isProxy(refCount);
const reactiveCount = reactive({ count: 0 });
const isProxyReactiveCount = isProxy(reactiveCount);
const reactiveCount = reactive({ count: 0 });
const isProxyReactiveCount = isProxy(reactiveCount);
const readonlyCount = readonly({ count: 0 });
const isProxyReadonlyCount = isProxy(readonlyCount);
const readonlyCount = readonly({ count: 0 });
const isProxyReadonlyCount = isProxy(readonlyCount);
const shallowReactiveCount = shallowReactive({ count: 0 });
const isProxyShallowReactiveCount = isProxy(shallowReactiveCount);
const shallowReactiveCount = shallowReactive({ count: 0 });
const isProxyShallowReactiveCount = isProxy(shallowReactiveCount);
const shallowReadonlyCount = shallowReadonly({ count: 0 });
const isProxyShallowReadonlyCount = isProxy(shallowReadonlyCount);
</script>
\ No newline at end of file
const shallowReadonlyCount = shallowReadonly({ count: 0 });
const isProxyShallowReadonlyCount = isProxy(shallowReadonlyCount);
</script>
......@@ -129,24 +129,27 @@ function transform(fileInfo, api) {
- [x] watchEffect
- [x] watchPostEffect
- [x] watchSyncEffect
- [ ] readonly
- [x] readonly
- [x] isProxy
- [ ] is-reactive
- [ ] isReadonly
- [ ] isRef
- [ ] toRef
- [ ] toRefs
- [ ] toValue
- [ ] unRef
- [ ] customRef
- [ ] effectScope
- [ ] getCurrentScope
- [ ] isProxy
- [ ] isReadonly
- [ ] isRef
- [ ] markRaw
- [ ] onScopeDispose
- [ ] shallowReactive
- [ ] shallowReadonly
- [ ] shallowRef
- [ ] toRaw
- [ ] toRef
- [ ] toRefs
- [ ] toValue
- [ ] triggerRef
- [ ] unRef
## directives
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册
新手
引导
客服 返回
顶部