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 ....

原文地址:https://www.cnblogs.com/xiangbei400G/p/12038864.html

时间: 2024-10-30 16:58:57

axios报错: Cannot read property 'protocol' of undefined ....的相关文章

Chrome下使用百度地图报错Cannot read property 'minZoom' of undefined

问题:工作中在Google chome下面的js console里面测试百度地图API var map = new BMap.Map("container"); map.centerAndZoom(new BMap.Point(116.404, 39.915), 11); TypeError: Cannot read property 'minZoom' of undefined message: "Cannot read property 'minZoom' of unde

echarts报错Cannot read property 'features' of undefined

引入地图的时候 echarts2报错: Uncaught Error: [MODULE_MISS]"echarts/src/util/mapData/params" is not exists! 原因不明,但是感觉和缺js文件有关(因为echarts3报错就是因为缺少了world.js) echarts3报错: Uncaught TypeError: Cannot read property 'features' of undefined 原因如下:缺少world.js,然后成功: 完

使用vue-preview报错Cannot read property 'open' of undefined

最近在做一个vue项目中时,需要使用vue-preview插件制作缩略图,首先在终端使用npm i vue-preview -S指令安装了vue-preview插件,然后在main.js中,导入并引用: import VuePreview from 'vue-preview' Vue.use(VuePreview) 接着在需要用到vue-preview插件的组件中写入: <img class="preview-img" v-for="(item, index) in l

在使用resetField 报错Cannot read property &#39;indexOf&#39; of undefined

elementUI  的resetField  是对对整个表单进行重置,将所有字段值重置为初始值并移除校验结果 ,当内容不一致 或找不到内容时 就会报错,具体原因举例如下: 原因1:ruleForm 内部数据 与实际页面需要验证的数据不一致 比如:下面例子 页面需要的是name ,而 ruleForm定义的是name2,当单词不小心写错就会报这个问题 <el-form ref="newFormModel" :rules="rules" :model="

使用UEditor 报错Cannot read property &#39;nodeType&#39; of undefined 解决办法

报如下错误 解决办法: //对编辑器的操作最好在编辑器ready之后再做 ue.ready(function() { }) <!-- 实例化编辑器 --> <script type="text/javascript"> $(function(){ var ue = UE.getEditor("container",{ autoHeight: false }); /对编辑器的操作最好在编辑器ready之后再做 ue.ready(function

angular ng build 报错 Cannot read property &#39;default&#39; of undefined

95% emitting index-html-webpack-plugin Cannot read property 'default' of undefinedTypeError: Cannot read property 'default' of undefined at compiler.hooks.emit.tapPromise (E:\projects\node_modules\@angular-devkit\build-angular\src\angular-cli-files\p

Vue ElementUI Axios报错: Uncaught (in promise) TypeError: Cannot read property &#39;$message&#39; of undefined

从头再来!!! 出错的代码如下: login() { this.loading = true let userInfo = {account: this.loginForm.account, password: this.loginForm.password, captcha: this.loginForm.chptcha} this.$api.login.login(userInfo).then( function(res) { if (res.msg != null) { this.$mes

dubbo-admin-2.5.3 运行报错: Bean property &#39;URIType&#39; is not writable or has an invalid

因为 jdk 是1.8的版本,和 dubbo-admin 存在兼容性问题.所以报错: Bean property 'URIType' is not writable or has an invalid 参见:https://github.com/alibaba/dubbo/issues/50 解决方法,修改 tomcat 默认的 jdk到 1.7 : 1) 修改bin文件夹下面的catalina.bat文件,把如下内容rem ----- Execute The Requested Command

Eclipse报错:Setting property &#39;source&#39; to &#39;org.eclipse.jst.jee.server:fzxt_tj&#39; did not find

在eclipse中启动tomcat时出现Setting property 'source' to 'org.eclipse.jst.jee.server:你的站点名'   did not find a matching property错误 解决办法: 1.在server控制台内,在服务器上点右键--属性 2.general选项卡中点switch location 这时,location变为:/servers/tomcat6.0 server at localhost.server 3.在pro