other原创
# reset
用于将已经有变动或更新的值重置到初始状态。
<template>
<view class="content">
<button @click="reset">重置</button>
</view>
</template>
<script setup lang="ts">
import { useXxxxStore } from '@/stores/Xxxx'
const Xxxx = useXxxxStore()
const reset = () => {
// 直接调用 pinia 的 $reset 即可,无参数。
Xxxx.$reset()
}
</script>
# subscribe
// 只要 Xxxx 里面的值有变动,就会触发
Xxxx.$subscribe((arags, state) => {
console.log('====>', arags) // 可以活期 state 相关参数 名称 新值 旧值等
console.log('====>', state) // 可以活期 state 相关参数 名称 新值 旧值等
})
上次更新: 2022/08/23, 18:12:45