Vue报错: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading ‘protocol‘)
- 问题原因,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‘)相关推荐
- vue Uncaught (in promise) TypeError: Cannot read properties of undefined (reading ‘comcode‘)
在查看信息时,界面没反应,然后查看控制台报错 index.vue?t=1680763420735:497 Uncaught (in promise) TypeError: Cannot read pr ...
- vue发送请求时遇到Uncaught (in promise) TypeError Cannot read properties of undefined(reading ‘randomExtend
最近在项目中遇到一个前端问题Uncaught (in promise) TypeError: Cannot read properties of undefined(reading 'randomEx ...
- 类似于#Uncaught (in promise) TypeError: Cannot read properties of undefined (reading ‘length‘)
类似于#Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'length') 报错显示某一属性 ...
- 修复报错 Error in render: “TypeError: Cannot read properties of undefined (reading ‘xxx‘)“
请求接口时,能够完整渲染出整体界面无问题,但是一刷新所渲染的界面就没了,并且开发者工具报出"Error in render: "TypeError: Cannot read pro ...
- vue发送请求时遇到index.vue?6ced:90 Uncaught (in promise) TypeError: Cannot read properties of undefined
项目中遇到问题如下: 查阅资料得知: 发请求的时候用的是异步模式,即使promise立刻被处理返回,但是浏览器在开始加载对象的时候,这个对象还是没有定义,所以也就读不到返回的值属性. 将原来的函数改为 ...
- vue3 Uncaught (in promise) TypeError: Cannot read properties of undefined 其实是解构赋值的问题
先看张图,好生奇怪,使用了v-for循环之后突然报错了. 在vue3中当我们用到了解构赋值配合reactive toRefs 方式渲染页面时,报错Uncaught (in promise) TypeE ...
- Uncaught (in promise)和Uncaught (in promise) TypeError: Cannot read properties of undefined (readin
只要在后面加上.catch((e) => {}),就不会报错了, const queGetdata = (params, context) => {return new Promise(( ...
- vue报错 Uncaught (in promise) NavigationDuplicated {_name:““NavigationDuplicated“... 的解决方法
vue报错 Uncaught (in promise) NavigationDuplicated {_name:""NavigationDuplicated"... 的解 ...
- vue报错Uncaught (in promise) NavigationDuplicated:Avoided redundant navigation
vue-router.esm.js?3423:2065 Uncaught (in promise) NavigationDuplicated: Avoided redundant navigation ...
最新文章
- 依赖包 全局_composer 更新指定的依赖包
- 【图片和pdf】相关网站
- linux中以A开头的函数使用方式历程及详解
- Android 5.1 SystemServer SystemService 各个系统Manager
- 使用FastJson解析时有关内部类的两个问题
- 记录——《C Primer Plus (第五版)》第十章编程练习第三题
- GAN诞生记:最火的AI模型,来自一群博士的酒后争吵
- 神经网络之激活函数(activation function)
- 笔记本Win10系统关于启动禁用触控板设置
- 实现商品库存信息管理页面
- android格式化通讯录
- 快乐大本营html5小游戏,快乐大本营小游戏规则-新年小游戏.doc
- 在java中move是什么意思_move是什么意思
- Day29 - Countdown Timer
- 10月25日 c语言 打印所有水仙花数
- 史上最全的CSS样式实现,提升你的效率
- IMS/SIP - GCF IMS相关认证测试如何通过看case procedure来得知哪些field/IE必须带?
- [转]国外人气最旺的软件测试网站
- 深入理解JavaScript系列(30):设计模式之外观模式
- 高德地图定位拖动改变位置