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 ....的主要内容,如果未能解决你的问题,请参考以下文章
vue3踩过的坑 - Cannot read property '$router' of undefined
axios报错:Cannot read property '$get' of undefined
解决报错:Uncaught TypeError: Cannot read properties of undefined (reading ‘install‘)
echarts报错Cannot read property 'features' of undefined
TypeError: Cannot read properties of undefined (reading ‘NAME‘)报错解决