ITPub博客

首页 > IT职业 > IT生活 > vue2.0入手踩的第三个坑-网络请求

vue2.0入手踩的第三个坑-网络请求

IT生活 作者:TigerJin 时间:2021-09-09 09:49:53 0 删除 编辑

Uncaught (in promise) TypeError: Cannot read property 'protocol' of undefined


1:浏览器报错
Uncaught (in promise) TypeError: Cannot read property 'protocol' of undefined


图片描述

浏览器报错.png

2:源码
错误的:

Vue.use(axios,VueAxios)

修正后:

Vue.use(VueAxios,axios)

完整代码:

import Vue from 'vue'import App from './App'import router from './router'import axios from 'axios'import VueAxios from 'vue-axios'//使用组件-模块化思想Vue.use(VueAxios,axios)/* eslint-disable no-new */new Vue({  el: '#app',
  router,  render: h => h(App)
});

3:原因:
有个先后问题,谁在前,依赖前置问题,自己的结论,未必对。没深入探索。



作者:麦壳儿UIandFE2
链接:https://www.jianshu.com/p/99574ff06368


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/2144/viewspace-2813103/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2020-06-28

  • 博文量
    494
  • 访问量
    25771