提交 217b2b73 编写于 作者: DCloud-WZF's avatar DCloud-WZF :speech_balloon:

refactor(reactivity): getCurrentScope

上级 e3a4ded2
......@@ -586,6 +586,11 @@ export default {
name: 'effectScope',
url: 'effect-scope/effect-scope'
},
{
id: 'get-current-scope',
name: 'getCurrentScope',
url: 'get-current-scope/get-current-scope'
},
]
}
] as Page[]
......
const PAGE_PATH = '/pages/composition-api/reactivity/get-current-scope/get-current-scope'
const PAGE_PATH = '/pages/reactivity/advanced/get-current-scope/get-current-scope'
describe('getCurrentScope', () => {
let page = null
......@@ -8,11 +8,11 @@ describe('getCurrentScope', () => {
})
it('basic', async () => {
const hasCurrentScope = await page.$('#has-current-scope')
expect(await hasCurrentScope.text()).toBe('hasCurrentScope: false')
expect(await hasCurrentScope.text()).toBe('false')
const createScopeBtn = await page.$('#create-scope-btn')
await createScopeBtn.tap()
expect(await hasCurrentScope.text()).toBe('hasCurrentScope: true')
expect(await hasCurrentScope.text()).toBe('true')
})
})
\ No newline at end of file
<template>
<view class="page">
<text id="has-current-scope">hasCurrentScope: {{ hasCurrentScope }}</text>
<button id="create-scope-btn" class="mt-10" @click="createScope">create scope</button>
<view class="flex justify-between flex-row mb-10">
<text>hasCurrentScope:</text>
<text id="has-current-scope">{{ hasCurrentScope }}</text>
</view>
<button id="create-scope-btn" class="mt-10" @click="createScope">
create scope
</button>
</view>
</template>
<script setup>
const hasCurrentScope = ref(false)
const createScope = () => {
const scope = effectScope()
scope.run(() => {
hasCurrentScope.value = getCurrentScope() !== null
})
}
</script>
\ No newline at end of file
<script setup lang="uts">
const hasCurrentScope = ref(false);
const createScope = () => {
const scope = effectScope();
scope.run(() => {
hasCurrentScope.value = getCurrentScope() !== null;
});
};
</script>
......@@ -142,7 +142,7 @@ function transform(fileInfo, api) {
- [x] customRef
- [x] effectScope
- [ ] getCurrentScope
- [x] getCurrentScope
- [ ] markRaw
- [ ] onScopeDispose
- [ ] shallowReactive
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册