当前位置:   article > 正文

Vue报错 TypeError Cannot read properties of undefined (reading ‘protocol‘)_typeerror: cannot read properties of undefined (re

typeerror: cannot read properties of undefined (reading 'protocol')

Vue报错: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading ‘protocol’)

  • 报错信息:

    Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'protocol')
    at isURLSameOrigin (isURLSameOrigin.js?3934:57)
    at dispatchXhrRequest (xhr.js?b50d:145)
    at new Promise (<anonymous>)
    at xhrAdapter (xhr.js?b50d:15)
    at dispatchRequest (dispatchRequest.js?5270:58)
    at Axios.request (Axios.js?0a06:108)
    at wrap (bind.js?1d2b:9)
    at Function.Vue.use (vue.runtime.esm.js?2b0e:5123)
    at eval (main.js?56d7:17)
    at Module../src/main.js (app.js:1134)
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
  • 问题原因,main.js中引用axios区别:

    import axios from “axios”;

    Vue.use(axios);

  • 正确写法:

    import axios from “axios”;

    Vue.prototype.axios = axios;

vue.use和vue.prot
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/IT小白/article/detail/288576?site
推荐阅读
相关标签
  

闽ICP备14008679号