isURLSameOrigin.js:57 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'protocol')
时间: 2023-10-17 14:25:11 浏览: 218
JQuery报错Uncaught TypeError: Illegal invocation的处理方法
报错信息"Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'protocol')"出现在isURLSameOrigin.js文件的第57行。该错误通常是由于无法读取未定义对象的属性引起的。
这个错误通常在使用axios库时出现,原因是在main.js文件中错误地引用了axios。正确的写法是将axios赋值给Vue实例的原型属性。即使用Vue.prototype.axios = axios;。而不是使用Vue.use(axios);
更具体地说,这个错误可能是由于在使用axios发送请求之前没有正确配置axios实例所致。在配置axios实例时,应该使用Vue.prototype.axios = axios;来将axios赋值给Vue的原型属性,以便在组件中使用axios进行请求。
总结一下,问题的原因是在使用axios时出现了错误的引用方式,正确的写法是将axios赋值给Vue的原型属性。这样可以避免出现"Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'protocol')"的错误。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [Vue报错: TypeError: Cannot read properties of undefined (reading ‘protocol‘)](https://blog.csdn.net/qq_45934504/article/details/121451597)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *2* [axios出错](https://blog.csdn.net/qq_27009517/article/details/120670701)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *3* [JQuery报错Uncaught TypeError: Illegal invocation的处理方法](https://download.csdn.net/download/weixin_38666230/13034647)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
[ .reference_list ]
阅读全文