引入使用该插件使用时发现不生效
原因:pinia实例调用顺序不当
将:
// import './assets/main.css'
import { createApp } from 'vue'
import { createPinia } from 'pinia'
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
import App from './App.vue'
import router from './router'
//引入初始化样式文件
import '@/styles/common.scss'
//引入懒加载指令插件并且注册
import { lazyPlugin } from './directives'
// 引入全局组件插件
import { componentPlugin } from '@/components'
const app = createApp(App)
const pinia = createPinia()
app.use(pinia)
pinia.use(piniaPluginPersistedstate)
app.use(componentPlugin)
app.use(router)
app.use(lazyPlugin)
app.mount('#app')
改为
// import './assets/main.css'
import { createApp } from 'vue'
import { createPinia } from 'pinia'
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
import App from './App.vue'
import router from './router'
//引入初始化样式文件
import '@/styles/common.scss'
//引入懒加载指令插件并且注册
import { lazyPlugin } from './directives'
// 引入全局组件插件
import { componentPlugin } from '@/components'
const app = createApp(App)
const pinia = createPinia()
pinia.use(piniaPluginPersistedstate)
app.use(pinia)
app.use(componentPlugin)
app.use(router)
app.use(lazyPlugin)
app.mount('#app')
标签:插件,app,use,pinia,persistedstate,import,App
From: https://blog.csdn.net/m0_74963840/article/details/140939148