fix(pinia): 处理小程序环境,pinia-plugin-persistedstate 不生效BUG
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// src/store/use_count_store.ts
|
||||
// src/store/useCountStore.ts
|
||||
import { defineStore } from 'pinia'
|
||||
import { ref } from 'vue'
|
||||
|
||||
|
||||
@@ -1,8 +1,15 @@
|
||||
// src/store/index.ts
|
||||
import { createPinia } from 'pinia'
|
||||
import piniaPersist from 'pinia-plugin-persistedstate' // 数据持久化
|
||||
import { createPersistedState } from 'pinia-plugin-persistedstate' // 数据持久化
|
||||
|
||||
const store = createPinia()
|
||||
store.use(piniaPersist)
|
||||
store.use(
|
||||
createPersistedState({
|
||||
storage: {
|
||||
getItem: uni.getStorageSync,
|
||||
setItem: uni.setStorageSync,
|
||||
},
|
||||
}),
|
||||
)
|
||||
|
||||
export default store
|
||||
|
||||
Reference in New Issue
Block a user