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

feat(composition api): getCurrentScope

上级 fa0f47af
const PAGE_PATH = '/pages/composition-api/reactivity/get-current-scope/get-current-scope'
describe('getCurrentScope', () => {
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 hasCurrentScope = await page.$('#has-current-scope')
expect(await hasCurrentScope.text()).toBe('hasCurrentScope: false')
const createScopeBtn = await page.$('#create-scope-btn')
await createScopeBtn.tap()
expect(await hasCurrentScope.text()).toBe('hasCurrentScope: true')
})
} else {
it('other platform', () => {
expect(1).toBe(1)
})
}
})
\ No newline at end of file
<template><view class="page">effectScope</view></template>
\ No newline at end of file
<template>
<view class="page">
<text id="has-current-scope">hasCurrentScope: {{ hasCurrentScope }}</text>
<button id="create-scope-btn" class="uni-common-mt" @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
......@@ -206,7 +206,7 @@
{
name: 'getCurrentScope',
url: 'get-current-scope',
enable: false,
enable: true,
},
{
name: 'onScopeDispose',
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册