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

refactor(reactivity): unRef

上级 fda5e7b4
......@@ -522,55 +522,55 @@
}
},
{
"path": "pages/reactivity/utilities/is-ref/is-ref",
"path": "pages/reactivity/utilities/is-proxy/is-proxy",
"style": {
"navigationBarTitleText": "isRef"
"navigationBarTitleText": "isProxy"
}
},
{
"path": "pages/reactivity/utilities/un-ref/un-ref",
"path": "pages/reactivity/utilities/is-reactive/is-reactive",
"style": {
"navigationBarTitleText": "unRef"
"navigationBarTitleText": "isReactive"
}
},
{
"path": "pages/reactivity/utilities/to-ref/to-ref",
"path": "pages/reactivity/utilities/is-readonly/is-readonly",
"style": {
"navigationBarTitleText": "toRef"
"navigationBarTitleText": "isReadonly"
}
},
// #ifdef APP
{
"path": "pages/reactivity/utilities/to-refs/to-refs",
"path": "pages/reactivity/utilities/is-ref/is-ref",
"style": {
"navigationBarTitleText": "toRefs"
"navigationBarTitleText": "isRef"
}
},
{
"path": "pages/reactivity/utilities/to-value/to-value",
"path": "pages/reactivity/utilities/un-ref/un-ref",
"style": {
"navigationBarTitleText": "toValue"
"navigationBarTitleText": "unRef"
}
},
// #endif
{
"path": "pages/reactivity/utilities/is-proxy/is-proxy",
"path": "pages/reactivity/utilities/to-ref/to-ref",
"style": {
"navigationBarTitleText": "isProxy"
"navigationBarTitleText": "toRef"
}
},
// #ifdef APP
{
"path": "pages/reactivity/utilities/is-reactive/is-reactive",
"path": "pages/reactivity/utilities/to-refs/to-refs",
"style": {
"navigationBarTitleText": "isReactive"
"navigationBarTitleText": "toRefs"
}
},
{
"path": "pages/reactivity/utilities/is-readonly/is-readonly",
"path": "pages/reactivity/utilities/to-value/to-value",
"style": {
"navigationBarTitleText": "isReadonly"
"navigationBarTitleText": "toValue"
}
},
// #endif
{
"path": "pages/reactivity/advanced/shallow-ref/shallow-ref",
"style": {
......
......@@ -565,6 +565,11 @@ export default {
url: 'to-value/to-value'
},
// #endif
{
id: 'un-ref',
name: 'unRef',
url: 'un-ref/un-ref'
},
]
}
] as Page[]
......
const PAGE_PATH = '/pages/composition-api/reactivity/un-ref/un-ref'
const PAGE_PATH = '/pages/reactivity/utilities/un-ref/un-ref'
describe('unref', () => {
let page = null
......@@ -6,15 +6,16 @@ describe('unref', () => {
page = await program.reLaunch(PAGE_PATH)
await page.waitFor('view')
})
it('basic', async () => {
const refCount = await page.$('#ref-count')
expect(await refCount.text()).toBe('ref count: 0')
expect(await refCount.text()).toBe('0')
const refCountType = await page.$('#ref-count-type')
expect(await refCountType.text()).toBe('ref count type: object')
expect(await refCountType.text()).toBe('object')
const count = await page.$('#count')
expect(await count.text()).toBe('count: 0')
expect(await count.text()).toBe('0')
const isRefCount = await page.$('#count-type')
expect(await isRefCount.text()).toBe('count type: number')
expect(await isRefCount.text()).toBe('number')
})
})
\ No newline at end of file
<template>
<view class="page">
<text id="ref-count">ref count: {{ refCount }}</text>
<text class="mt-10" id="ref-count-type">ref count type: {{ refCountType }}</text>
<text class="mt-10" id="count">count: {{ count }}</text>
<text class="mt-10" id="count-type">count type: {{ countType }}</text>
<view class="flex justify-between flex-row mb-10">
<text>ref count:</text>
<text id="ref-count">{{ refCount }}</text>
</view>
<view class="flex justify-between flex-row mb-10">
<text>ref count type:</text>
<text id="ref-count-type">{{ refCountType }}</text>
</view>
<view class="flex justify-between flex-row mb-10">
<text>count:</text>
<text id="count">{{ count }}</text>
</view>
<view class="flex justify-between flex-row mb-10">
<text>count type:</text>
<text id="count-type">{{ countType }}</text>
</view>
</view>
</template>
<script setup>
const refCount = ref<number>(0);
const refCountType = typeof refCount;
const count = unref(refCount);
const countType = typeof count;
</script>
\ No newline at end of file
<script setup lang="uts">
const refCount = ref<number>(0);
const refCountType = typeof refCount;
const count = unref(refCount);
const countType = typeof count;
</script>
......@@ -138,7 +138,7 @@ function transform(fileInfo, api) {
- [x] toRef
- [x] toRefs
- [x] toValue
- [ ] unRef
- [x] unRef
- [ ] customRef
- [ ] effectScope
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册