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

当组件被卸载时subscriptions将被自动删除 #54

Open zyd19960625 opened 2 years ago

zyd19960625 commented 2 years ago

默认情况下,state subscriptions 绑定到添加它们的组件(如果 store 位于组件的 setup() 中)。 意思是,当组件被卸载时,它们将被自动删除。 如果要在卸载组件后保留它们,请将 { detached: true } 作为第二个参数传递给 detach 当前组件的 state subscription

see here

store.$subscribe(() => {
      strategies.forEach((strategy) => {
        updateStorage(strategy, store);
      });
},{ detached: true });
wa-monster commented 1 year ago

我也遇到这个了,但是这个绑定到添加他们的组件具体是什么意思了