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

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的话需要修改一下。
在这里插入图片描述
修改成下面这个格式

import {
    
     createStore } from 'vuex'

export default createStore({
    
    
    state: {
    
    
        
    }
})

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_51447496/article/details/131053428
今日推荐