修改浅层state
// 直接在模板中操作
<script lang='ts' setup>
......
const demoStore = DemoStore();
function changeState(val: any){
demoStore.$patch({demoData: val})
}
......
</script>
修改深层state
// 直接在模板中操作
<script lang='ts' setup>
......
const demoStore = DemoStore();
function changeState(index: number, val: any){
demoStore.$patch(state => {
state.demoArray[index] = val;
});
}
......
</script>