<template>
<view class="child">
<view class="flex-row">
<text>孙组件:</text>
<text class="grandchild-msg">{{ msg }}</text>
</view>
<button class="grandchild-btn" @click="change">孙组件清空数据</button>
</view>
</template>
<script setup>
import { state, setComponentMsg } from '@/store/index.uts'
const msg = computed((): number => state.componentMsg)
const change = () => {
setComponentMsg(0)
}
</script>
<style>
.child {
margin-top: 10px;
}
</style>