fix(pinia): 处理小程序环境,pinia-plugin-persistedstate 不生效BUG
This commit is contained in:
parent
5ff6009dd1
commit
d17e8fa76d
@ -62,6 +62,7 @@ module.exports = {
|
|||||||
'no-plusplus': 'off',
|
'no-plusplus': 'off',
|
||||||
'no-shadow': 'off',
|
'no-shadow': 'off',
|
||||||
'vue/multi-word-component-names': 'off',
|
'vue/multi-word-component-names': 'off',
|
||||||
|
'@typescript-eslint/no-explicit-any': 'off',
|
||||||
},
|
},
|
||||||
// eslint-import-resolver-typescript 插件,@see https://www.npmjs.com/package/eslint-import-resolver-typescript
|
// eslint-import-resolver-typescript 插件,@see https://www.npmjs.com/package/eslint-import-resolver-typescript
|
||||||
settings: {
|
settings: {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// src/store/use_count_store.ts
|
// src/store/useCountStore.ts
|
||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
|
|
||||||
|
@ -1,8 +1,15 @@
|
|||||||
// src/store/index.ts
|
// src/store/index.ts
|
||||||
import { createPinia } from 'pinia'
|
import { createPinia } from 'pinia'
|
||||||
import piniaPersist from 'pinia-plugin-persistedstate' // 数据持久化
|
import { createPersistedState } from 'pinia-plugin-persistedstate' // 数据持久化
|
||||||
|
|
||||||
const store = createPinia()
|
const store = createPinia()
|
||||||
store.use(piniaPersist)
|
store.use(
|
||||||
|
createPersistedState({
|
||||||
|
storage: {
|
||||||
|
getItem: uni.getStorageSync,
|
||||||
|
setItem: uni.setStorageSync,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
|
||||||
export default store
|
export default store
|
||||||
|
Loading…
x
Reference in New Issue
Block a user