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

feat(composition api): toRaw

上级 027548a7
const PAGE_PATH = '/pages/composition-api/reactivity/to-raw/to-raw'
describe('toRaw', () => {
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 checkToRawRef = await page.$('#check-to-raw-ref')
expect(await checkToRawRef.text()).toBe('check toRaw ref: false')
const checkToRawReactive = await page.$('#check-to-raw-reactive')
expect(await checkToRawReactive.text()).toBe('check toRaw reactive: true')
const checkToRawReadonly = await page.$('#check-to-raw-readonly')
expect(await checkToRawReadonly.text()).toBe('check toRaw readonly: true')
const checkToRawShallowReactive = await page.$('#check-to-raw-shallow-reactive')
expect(await checkToRawShallowReactive.text()).toBe('check toRaw shallowReactive: true')
const checkToRawShallowReadonly = await page.$('#check-to-raw-shallow-readonly')
expect(await checkToRawShallowReadonly.text()).toBe('check toRaw shallowReadonly: true')
})
} else {
it('other platform', () => {
expect(1).toBe(1)
})
}
})
\ No newline at end of file
<template><view class="page">toRaw</view></template>
\ No newline at end of file
<template>
<view class="page">
<text id="check-to-raw-ref">check toRaw ref: {{ checkToRawRef }}</text>
<text class="uni-common-mt" id="check-to-raw-reactive">check toRaw reactive: {{ checkToRawReactive }}</text>
<text class="uni-common-mt" id="check-to-raw-readonly">check toRaw readonly: {{ checkToRawReadonly }}</text>
<text class="uni-common-mt" id="check-to-raw-shallow-reactive">check toRaw shallowReactive:
{{ checkToRawShallowReactive }}</text>
<text class="uni-common-mt" id="check-to-raw-shallow-readonly">check toRaw shallowReadonly:
{{ checkToRawShallowReadonly }}</text>
</view>
</template>
<script setup>
const obj = {}
const refObj = ref(obj);
const checkToRawRef = toRaw<UTSJSONObject>(refObj) === obj;
const reactiveObj = reactive(obj);
const checkToRawReactive = toRaw<UTSJSONObject>(reactiveObj) === obj;
const readonlyObj = readonly(obj);
const checkToRawReadonly = toRaw<UTSJSONObject>(readonlyObj) === obj;
const shallowReactiveObj = shallowReactive(obj);
const checkToRawShallowReactive = toRaw<UTSJSONObject>(shallowReactiveObj) === obj;
const shallowReadonlyObj = shallowReadonly(obj);
const checkToRawShallowReadonly = toRaw<UTSJSONObject>(shallowReadonlyObj) === obj;
</script>
\ No newline at end of file
......@@ -191,7 +191,7 @@
{
name: 'toRaw',
url: 'to-raw',
enable: false,
enable: true,
},
{
name: 'markRaw',
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册