axios报错: Cannot read property 'protocol' of undefined ....
Posted xiangbei400g
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了axios报错: Cannot read property 'protocol' of undefined ....相关的知识,希望对你有一定的参考价值。
错误:
Uncaught (in promise) TypeError: **Cannot read property 'protocol' of undefined ...
源码:
完整错误:
import axios from 'axios'
import VueAxios from 'vue-axios'
Vue.use(axios, VueAxios)
修正一:(亲测)
import axios from 'axios'
import VueAxios from 'vue-axios'
Vue.use(VueAxios, axios) // 交换位置
修正二:
import axios from 'axios'
//Vue.use(axios) // 不用这个
Vue.prototype.$http = axios // 挂载到原型
个人学习遇见的错误,方法整合自互联网。
以上是关于axios报错: Cannot read property 'protocol' of undefined ....的主要内容,如果未能解决你的问题,请参考以下文章
Vue ElementUI Axios报错: Uncaught (in promise) TypeError: Cannot read property '$message' of u
为啥我有 TypeError: Cannot read property 'protocol' of undefined using axios with vue?
将数据传递给模态:Property/method props undefined & TypeError: Cannot read property product of undefined
VUE - 使用axios数据请求时数据绑定时 报错 TypeError: Cannot set property 'xxxx' of undefined 的解决办法
vue添加组件报错 Cannot read properties of undefined (reading ‘toLowerCase‘)