美文网首页
vue用axios时报错:Cannot read propert

vue用axios时报错:Cannot read propert

作者: 刘松阳 | 来源:发表于2020-05-20 13:36 被阅读0次

    import Vue from 'vue'

    import Vuex from 'vuex'

    import axios from 'axios'

    Vue.use(Vuex)

    Vue.use(axios)

    报错信息:

    isURLSameOrigin.js?cf95:57 Uncaught (in promise) TypeError: Cannot

    read property 'protocol' of undefined

    at isURLSameOrigin (eval at <anonymous> (app.js:929), <anonymous>:57:21)

    at dispatchXhrRequest (eval at <anonymous> (app.js:754), <anonymous>:108:50)

    at Promise (<anonymous>)

    at xhrAdapter (eval at <anonymous> (app.js:754), <anonymous>:12:10)

    at dispatchRequest (eval at <anonymous> (app.js:866), <anonymous>:52:10)

    报错截图:

    https://img1.sycdn.imooc.com/5c30712900018d9e06840122.jpg

    但是,通过原型方式使用就正常:

    import Vue from 'vue'

    import Vuex from 'vuex'

    import axios from 'axios'

    Vue.use(Vuex)

    Vue.prototype.$ajax = axios

    相关文章

      网友评论

          本文标题:vue用axios时报错:Cannot read propert

          本文链接:https://www.haomeiwen.com/subject/btzplhtx.html