Uncaught Error: [**]: getActivePinia was called with no active Pinia. Did you forget to install pinia? - 前端笔记-pinia 报错:如下 pinia.esm-browser.js:1671 Uncaught Error: [**]: getActivePinia was called wi...

学习笔记

点滴记忆
回忆过往
首页>> web前端 >>Uncaught Error: [**]: getActivePinia was called with no active Pinia. Did you forget to install pinia? - 前端笔记

pinia 报错:如下
pinia.esm-browser.js:1671 
        
       Uncaught Error: [**]: getActivePinia was called with no active Pinia. Did you forget to install pinia?
	const pinia = createPinia()
	app.use(pinia)
This will fail in production.
    at useStore (pinia.esm-browser.js:1671:19)
    at index.ts:12:16
原因是在setup 之外调用了 usestore

本人是  初始化 vue-i18n的时候需要调用 pania做全局状态管理,语言方式的,突然出现 报错,解决办法如下:


只要初始化的 时候把 pinia实例传入进去就好

pinia创建的实例:=》

// https://pinia.vuejs.org/
// pinia 实例
import { createPinia } from 'pinia';

// 创建
const pinia = createPinia();

// 导出
export default pinia;

i18n的时候引入实例切传入:=》
import pania from '/@/stores/index'
// 解构赋值 响应式的
import {storeToRefs} from 'pinia';
import {useThemeConfig} from '/@/stores/themeConfig'

// 读取 pinia 默认语言
const stores = useThemeConfig(pania);

×

感谢您的支持,我们会一直保持!

扫码支持
请土豪扫码随意打赏

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

打赏作者
版权所有,转载注意明处:前端笔记 » Uncaught Error: [**]: getActivePinia was called with no active Pinia. Did you forget to install pinia?

发表评论

路人甲 表情
Ctrl+Enter快速提交

网友评论(0)