"getActivePinia()" was called but there was no active Pinia. Are you trying to use a store before calling "app.use(pinia)"?

使用pinia时候遇到的问题

 

使用pinia store必须在 组件的 setup 里面

vue-router路由文件需要在路由钩子里面用

报错之前代码--   

把  const userStore = useUserStore()
放在了 
router.beforeEach((to, from, next) 
钩子函数的
外面了

 

posted @ 2024-05-09 10:09  深海里的星星i  阅读(2309)  评论(0)    收藏  举报