错误信息如下所示:
isURLSameOrigin.js?3934:57 Uncaught (in promise) TypeError: Cannot read property 'protocol' of undefined
at isURLSameOrigin (isURLSameOrigin.js?3934:57)
at dispatchXhrRequest (xhr.js?b50d:103)
at new Promise (<anonymous>)
at xhrAdapter (xhr.js?b50d:11)
at dispatchRequest (dispatchRequest.js?5270:59)
问题代码,查看根目录main.js
中引入axios的代码,是否如下所示:
import axios from 'axios'
import qs from 'qs'
Vue.use(axios)
正确写法:
import axios from 'axios'
import qs from 'qs'
Vue.prototype.axios = axios