安装
npm install -S vuex-persist(yarn add vuex-persist)
使用:
main.js引入pinia-plugin-persist配置:
import { createApp } from 'vue'
import App from './App.vue'
import { createPinia } from 'pinia'
import piniaPersist from 'pinia-plugin-persist'
const pinia = createPinia()
pinia.use(piniaPersist) // 相当于vuex持久化存储
const app = createApp(App)
app.config.errorHandler = (err, instance, info) => {
// 全局应用错误监听
console.error('application-err:', err)
}
app.use(pinia).mount('#app')