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

feat(composition api): triggerRef

上级 460b2ff5
const PAGE_PATH = '/pages/composition-api/reactivity/trigger-ref/trigger-ref'
describe('triggerRef', () => {
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 stateCount = await page.$('#state-count')
expect(await stateCount.text()).toBe('state.count: 0')
const incrementStateCountBtn = await page.$('#increment-state-count-btn')
await incrementStateCountBtn.tap()
expect(await stateCount.text()).toBe('state.count: 0')
const triggerRefStateBtn = await page.$('#trigger-ref-state-btn')
await triggerRefStateBtn.tap()
expect(await stateCount.text()).toBe('state.count: 1')
})
} else {
it('other platform', () => {
expect(1).toBe(1)
})
}
})
\ No newline at end of file
<template><view class="page">triggerRef</view></template>
\ No newline at end of file
<template>
<view class="page">
<text id="state-count" class="uni-common-mb">state.count: {{ state['count'] }}</text>
<button id="increment-state-count-btn" class="uni-common-mb" @click="incrementStateCount">increment
state.count</button>
<button id="trigger-ref-state-btn" @click="triggerRefState">trigger state</button>
</view>
</template>
<script setup>
const state = shallowRef({
count: 0
})
const incrementStateCount = () => {
state.value.count++
}
const triggerRefState = () => {
triggerRef(state)
}
</script>
\ No newline at end of file
......@@ -171,7 +171,7 @@
{
name: 'triggerRef',
url: 'trigger-ref',
enable: false,
enable: true,
},
{
name: 'customRef',
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册