Vue报错“ Uncaught TypeError: Cannot read property ‘use‘ of undefined”

Love The Way You Lie 2024-03-16 13:37 209阅读 0赞

Vue报错“ Uncaught TypeError: Cannot read property ‘use‘ of undefined”

错误全程

Cannot read properties of undefined (reading ‘use’) TypeError: Cannot read properties of undefined (reading ‘use’) at eval (webpack-internal:///./src/store/index.js:6:45) at ./src/store/index.js (http://localhost:8080/js/app.js:96:1) at _

错误分析

这个错误说的是use这个方法没有定义
在这里插入图片描述
回到前端代码,发现这里使用了Vue.use,但是上面错误提示里面显示里面没有,原因是因为下面这个写法是Vue2的写法,vue3的话需要修改一下。
在这里插入图片描述
修改成下面这个格式

  1. import {
  2. createStore } from 'vuex'
  3. export default createStore({
  4. state: {
  5. }
  6. })

在这里插入图片描述

发表评论

表情:
评论列表 (有 0 条评论,209人围观)

还没有评论,来说两句吧...

相关阅读