vue3 使用axios 会报错“Uncaught TypeError: Cannot read property ‘get‘ of undefined”
程序员文章站
2022-07-03 10:39:58
...
原因是在main中,需要把“app.use(VueAxios, axios)”放在“app.mount(’#app’)”之前,如代码:
import { createApp } from 'vue'
import App from './App.vue'
import axios from 'axios'
import VueAxios from 'vue-axios'
import installElementPlus from './plugins/element.js'
const app = createApp(App)
installElementPlus(app)
app.use(VueAxios, axios)
app.mount('#app')
记录一下。
上一篇: Windows“启动”文件夹
推荐阅读
-
vue3 使用axios 会报错“Uncaught TypeError: Cannot read property ‘get‘ of undefined”
-
Vue框架的学习中,使用substring方法时提示:Uncaught TypeError: Cannot read property ‘substring‘ of undefined的解决方法
-
使用webpack命令打包时,报错TypeError: Cannot read property 'presetToOptions' of undefined的解决办法
-
js 报错 Uncaught TypeError: Cannot read property 'trim' of undefined
-
Vue框架的学习中,使用substring方法时提示:Uncaught TypeError: Cannot read property ‘substring‘ of undefined的解决方法
-
使用webpack命令打包时,报错TypeError: Cannot read property 'presetToOptions' of undefined的解决办法