vue报错TypeError: Cannot read property 'protocol' of undefined

错误信息如下所示:

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
上一篇:QP简介


下一篇:Django xadmin 根据登录用户过滤数据