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

refactor(composition api): triggerRef 优化类型

上级 77c0ab89
<template> <template>
<view class="page"> <view class="page">
<text id="state-count" class="uni-common-mb">state.count: {{ state['count'] }}</text> <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 <button id="increment-state-count-btn" class="uni-common-mb" @click="incrementStateCount">increment
state.count</button> state.count</button>
<button id="trigger-ref-state-btn" @click="triggerRefState">trigger state</button> <button id="trigger-ref-state-btn" @click="triggerRefState">trigger state</button>
...@@ -8,9 +8,12 @@ ...@@ -8,9 +8,12 @@
</template> </template>
<script setup> <script setup>
type State = {
count: number
}
const state = shallowRef({ const state = shallowRef({
count: 0 count: 0
}) } as State)
const incrementStateCount = () => { const incrementStateCount = () => {
state.value.count++ state.value.count++
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册