Seb-L / pinia-plugin-persist

Persist pinia state data in sessionStorage or other storages.
https://Seb-L.github.io/pinia-plugin-persist/
MIT License
214 stars 37 forks source link

Is $patch had no effect? #32

Closed ZengFanhui closed 2 years ago

ZengFanhui commented 2 years ago

app.js `import { defineStore } from 'pinia' import { ref, reactive } from 'vue'

export const useAppStore = defineStore('app', () => { // state const isCollapse = ref(false)

// actions function setIsCollapse(isCollapse) { this.isCollapse = isCollapse }

return { isCollapse setIsCollapse } }, { persist: { enabled: true, strategies: [ { key: 'appStore', storage: localStorage }, ] } }) ` isCollapse default value is false,in the page ,I clicked a button change value to true In localStorage ,have object { isCollapse: true }

then I refresh this page , isCollapse 's value should be true

but actually , the value is false

so I think is $patch had no effect?

image