插件默认使用 localStorage
实现持久化,小程序端不兼容,需要替换持久化 API
import { defineStore } from 'pinia'
export const useCommonStore = defineStore('pack-store', {state: (): State => ({wwInfo: {},globalData: {},timerLock: false, //是否关闭合成定时器}),getters: {},actions: {setWwInfo: (state: State, data: any) => {this.wwInfo = data;//注意这里不用加state。直接this就行}, },{// 配置持久化persist: {// 调整为兼容多端的APIstorage: {setItem(key, value) {uni.setStorageSync(key, value) },getItem(key) {return uni.getStorageSync(key) },},}, }, )