安装插件
npm i pinia-plugin-persistedstate
main.js中引入
import { createApp } from 'vue'
import { createPinia } from 'pinia'
import App from './App.vue'
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
// createApp(App).use(CreatePinia()).mount('#app')
const pinia = createPinia()
const app = createApp(App)
app.use(pinia.use(piniaPluginPersistedstate))
app.mount("#app")
用法