在优化vue的过程中,看到目前为止官方推荐的数据管理工具是pinia,而我使用的是vuex

pinia的迁移非常快捷方便

所以接下来简要说明一下迁移过程中遇到的问题

迁移问题

getActivePinia was called with no active Pinia. Did you forget to install pinia

根据官网迁移后,项目运行报以上错误

首先,我在main.ts已经初始化了的

import { createApp } from 'vue'
import { createPinia } from 'pinia'
import App from './App.vue'const pinia = createPinia()
const app = createApp(App)app.use(pinia)

以下是 project-pinia.ts 文件

export const useProjectStore = defineStore('project', {state: () => ({appName:"",lang:"",loginUser:{}})
})

对pinia的引用

const store = useProjectStore()

经过分析后发现是对pinia的引入如果早于app.use(pinia)就会报以上错误,可以仔细查找一下所有使用pinia的地方,是否有在创建以前就调用的,尤其是全局调用,例如在router等设置文件中设置或使用

例如:

//pinia方式
store.lang="zh_CN"

因为vuex在router文件或者main入口文件中,在app.use(store)之前设置是不会报错的,所以如果直接替换成pinia方式,会导致以上错误

//vuex方式
store.commit("setLang","zh_CN")

[pinia]报错信息:getActivePinia was called with no active Pinia. Did you forget to install pinia相关推荐

  1. 在router中使用pinia报错解决

    在router中使用pinia(getActivePinia was called with no active Pinia. Did you forget to install pinia)报错解决 ...

  2. 在ts文件中使用pinia报错解决

    在ts文件中使用pinia(getActivePinia was called with no active Pinia. Did you forget to install pinia)报错解决 一 ...

  3. React篇-报错信息:warning: Can't call setState (or forceUpdate) on an unmounted component.

    报错信息是: Warning: Can't call setState (or forceUpdate) on an unmounted component. This is a no-op, but ...

  4. 【报错信息】Google Play 上架报错 ( Your app contains ads that do not comply with our Families ad | 退出亲子同乐计划 )

    文章目录 一.报错信息 二.向 Google Play 政策团队询问细节信息 三.解决方案 ( 暂时 ) 一.报错信息 Google Play 上架应用 , 又又又被拒了 ; 报错信息 : Hi De ...

  5. 【Android NDK 开发】NDK C/C++ 代码崩溃调试 - Tombstone 报错信息日志文件分析 ( 获取 tombstone_0X 崩溃日志信息 )

    文章目录 一.崩溃信息描述 二.手机命令行操作 三.电脑命令行操作 四.Tombstone 内容 Tombstone 报错信息日志文件被保存在了 /data/tombstones/ 目录下 , 先 R ...

  6. 【Android 安全】DEX 加密 ( Proguard 混淆 | 混淆后的报错信息 | Proguard 混淆映射文件 mapping.txt )

    文章目录 一.Proguard 混淆后的报错信息 二.Proguard 混淆映射文件 mapping.txt 更多 ProGuard 混淆配置参考 : https://www.guardsquare. ...

  7. JavaWeb: 报错信息The superclass javax.servlet.http.HttpServlet was not found on the Java Build Path...

    JavaWeb: 报错信息The superclass "javax.servlet.http.HttpServlet" was not found on the Java Bui ...

  8. 报错信息为:Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded datasource

    报错信息为:Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource ...

  9. Hadoop报错信息:Job not successful. Error: # of failed Map Tasks exceeded allowed limit. FailedCount: 4.

    Hadoop报错信息如下: 120 15/01/27 15:48:23 ERROR streaming.StreamJob: Job not successful. Error: # of faile ...

最新文章

  1. mysql8 mac 忘记密码_mac下 MySql 8.0.15忘记密码重置密码
  2. Nginx设置静态页面压缩和缓存过期时间的方法 (转)
  3. mysql将权限分为几个层级_MySQL多层级结构-区域表使用树详解
  4. 各层电子数排布规则_原子核外电子排布原理
  5. scrapy使用selenium抓取深圳证券交易所考评表数据
  6. (58)Verilog HDL事件或:or、,
  7. iOS蓝牙原生封装,助力智能硬件开发
  8. 张一鸣倡议AI发展要讲责任,马维英谈头条AI现状和未来 | 实录
  9. ReportView动态加载带参数的RDCL文件
  10. SpringSecurity+SpringSocial 实现QQ登入(一)
  11. java ckfinder_java 使用ckfinder
  12. javascript技巧收集(200多个)
  13. ubuntu系统中webpy的使用
  14. 获取地理位置定位信息-app端
  15. 电脑重装系统word从第二页开始有页眉页脚如何设置
  16. CTR --- NFM论文阅读笔记,及tf2复现
  17. Python_小林的爬取QQ空间相册图片链接程序
  18. mysql数据库时区配置
  19. MATLAB中datetime函数的使用
  20. 专利申请预审需要满足什么条件?

热门文章

  1. java中URL地址中文乱码问题
  2. python waitkey_OpenCV Python视频播放 – 如何为cv2.waitKey()设置正确的延迟
  3. c++ 按键暂停继续 程序_C++ 实现按任意键继续~~~
  4. Java面试题Tomcat的优化经验
  5. hexdump的使用
  6. 微型计算机数据传输接口40,微型計算机系统.ppt
  7. java redis监控工具_聊聊redis的监控工具
  8. CP936 转换成 UTF-8
  9. centos挂载硬盘和修改挂载硬盘
  10. 2020新年贺岁C++实战开发