vue用axios时报错:Cannot read property 'protocol' of undefined!
importVuefrom 'vue'import Vuex from 'vuex'import axios from 'axios'Vue.use(Vuex)Vue.use(axios)报错信息:isURLSameOrigin.js?cf95:57 Uncaught (in promise) TypeError: Cannotread property 'protoc...
·
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)
报错截图:
但是:通过原型式使用就正常了:
import Vue from 'vue'
import Vuex from 'vuex'
import axios from 'axios'
Vue.use(Vuex)
Vue.prototype.$ajax = axios
更多推荐
已为社区贡献9条内容
所有评论(0)