(已解决)解决Vue3在使用 vue add axios时报错:Cannot read properties of undefined (reading ‘use‘)

一:问题的描述

刚入门前端的小白,在学习Vue的前后端分离项目的时候,使用 vue add axios 安装插件准备进行前后端的数据交互,出现了Cannot read properties of undefined (reading ‘use’)错误

二:问题原因

Vue2在安装插件时候使用的是: Vue.use(Plugin) ,而在Vue3不再支持这种方式

三:问题解决

1.在目录 src->plugins->axios.js 找到 Vue.use(Plugin) 删除或者注释掉

2.在main.js下添加这行代码

createApp(App).use(store).use(axios).mount('#app')

就可以运行了

猜你喜欢

转载自blog.csdn.net/qq_41264451/article/details/128614810
今日推荐