import Vue from 'vue'
import Vuex from 'vuex'
import axios from 'axios'
Vue.use(Vuex)
Vue.use(axios)
Error message:
isURLSameOrigin.js?cf95:57 Uncaught (in promise) TypeError: Cannot
read property 'protocol' of undefinedat 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)
Error screenshot:
But, using it in prototype mode is normal:
import Vue from 'vue'
import Vuex from 'vuex'
import axios from 'axios'
Vue.use(Vuex)
Vue.prototype.$ajax = axios
Why do some people always think that axios is a vue plug-in. . By the way, there is somewhere written for you to use Vue.use(axios). .