• 问题原因,main.js中引用axios区别:
import axios from "axios";Vue.use(axios);
  • 正确写法:
import axios from "axios";Vue.prototype.axios = axios;

通过调查资料了解到:

1、不是为了vue写的插件(插件内要处理)不支持Vue.use()加载方式
2、非vue官方库不支持new Vue()方式
3、每一个vue组件都是Vue的实例,所以组件内this可以拿到Vue.prototype上添加加的属性和方法

import from "vuex";        // 官方插件vuex
Vue.use(Vuex);
Vue.prototype.axios = axios;

主要是由于插件内部编码方式不同,axios不是按照vue规则设计的插件(准确地说不是专门为vue服务),建议用Vue.prototype添加到vue原型链上使用;

Vue报错: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading ‘protocol‘)相关推荐

  1. vue Uncaught (in promise) TypeError: Cannot read properties of undefined (reading ‘comcode‘)

    在查看信息时,界面没反应,然后查看控制台报错 index.vue?t=1680763420735:497 Uncaught (in promise) TypeError: Cannot read pr ...

  2. vue发送请求时遇到Uncaught (in promise) TypeError Cannot read properties of undefined(reading ‘randomExtend

    最近在项目中遇到一个前端问题Uncaught (in promise) TypeError: Cannot read properties of undefined(reading 'randomEx ...

  3. 类似于#Uncaught (in promise) TypeError: Cannot read properties of undefined (reading ‘length‘)

    类似于#Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'length') 报错显示某一属性 ...

  4. 修复报错 Error in render: “TypeError: Cannot read properties of undefined (reading ‘xxx‘)“

    请求接口时,能够完整渲染出整体界面无问题,但是一刷新所渲染的界面就没了,并且开发者工具报出"Error in render: "TypeError: Cannot read pro ...

  5. vue发送请求时遇到index.vue?6ced:90 Uncaught (in promise) TypeError: Cannot read properties of undefined

    项目中遇到问题如下: 查阅资料得知: 发请求的时候用的是异步模式,即使promise立刻被处理返回,但是浏览器在开始加载对象的时候,这个对象还是没有定义,所以也就读不到返回的值属性. 将原来的函数改为 ...

  6. vue3 Uncaught (in promise) TypeError: Cannot read properties of undefined 其实是解构赋值的问题

    先看张图,好生奇怪,使用了v-for循环之后突然报错了. 在vue3中当我们用到了解构赋值配合reactive toRefs 方式渲染页面时,报错Uncaught (in promise) TypeE ...

  7. Uncaught (in promise)和Uncaught (in promise) TypeError: Cannot read properties of undefined (readin

    只要在后面加上.catch((e) => {}),就不会报错了, const queGetdata = (params, context) => {return new Promise(( ...

  8. vue报错 Uncaught (in promise) NavigationDuplicated {_name:““NavigationDuplicated“... 的解决方法

    vue报错 Uncaught (in promise) NavigationDuplicated {_name:""NavigationDuplicated"... 的解 ...

  9. vue报错Uncaught (in promise) NavigationDuplicated:Avoided redundant navigation

    vue-router.esm.js?3423:2065 Uncaught (in promise) NavigationDuplicated: Avoided redundant navigation ...

最新文章

  1. 依赖包 全局_composer 更新指定的依赖包
  2. 【图片和pdf】相关网站
  3. linux中以A开头的函数使用方式历程及详解
  4. Android 5.1 SystemServer SystemService 各个系统Manager
  5. 使用FastJson解析时有关内部类的两个问题
  6. 记录——《C Primer Plus (第五版)》第十章编程练习第三题
  7. GAN诞生记:最火的AI模型,来自一群博士的酒后争吵
  8. 神经网络之激活函数(activation function)
  9. 笔记本Win10系统关于启动禁用触控板设置
  10. 实现商品库存信息管理页面
  11. android格式化通讯录
  12. 快乐大本营html5小游戏,快乐大本营小游戏规则-新年小游戏.doc
  13. 在java中move是什么意思_move是什么意思
  14. Day29 - Countdown Timer
  15. 10月25日 c语言 打印所有水仙花数
  16. 史上最全的CSS样式实现,提升你的效率
  17. IMS/SIP - GCF IMS相关认证测试如何通过看case procedure来得知哪些field/IE必须带?
  18. [转]国外人气最旺的软件测试网站
  19. 深入理解JavaScript系列(30):设计模式之外观模式
  20. 高德地图定位拖动改变位置

热门文章

  1. 网站启用GZip压缩后,速度快了3倍!
  2. 题目:【正月初八】开工大吉,事业新启,红红火火!
  3. linux怎么卸载vmtools,linux卸载vmtools
  4. flex匹配json number, string
  5. 【XSY2668】排列统计 DP
  6. 使用mybatis-plus基于BaseMapper的Page对象按条件分页查询
  7. windows 由于使用代理,有时候部分浏览器网页打不开 解决方法
  8. 向量点乘叉乘推导公式
  9. C++老矣,尚能饭否?
  10. 网络安全面试的HTTPS问题_HTTPS原理剖析