🍍 在 vue-router 中使用 pinia 报错解决

·  阅读 260

Uncaught Error: [🍍]: getActivePinia was called with no active Pinia. Did you forget to install pinia?

store:

import { createPinia } from 'pinia'
const pinia = createPinia()
export default pinia;
复制代码

main.ts:

import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import pinia from './storePinia'

createApp(App)
    .use(router)
    .use(pinia)
    .mount('#app')
复制代码

router:

import pinia from '@/storePinia' 
import { useKeepAlive } from '@/storePinia/keepAlive';
const keepAlive = useKeepAlive(pinia);
复制代码
分类:
前端
收藏成功!
已添加到「」, 点击更改