Vue引入axios报错TypeError Cannot read property protocol of undefined

错误信息

Uncaught (in promise) TypeError: Cannot read property 'protocol' of undefined
    at isURLSameOrigin (isURLSameOrigin.js?3934:57)
    at dispatchXhrRequest (xhr.js?b50d:109)
    at new Promise (<anonymous>)
    at xhrAdapter (xhr.js?b50d:12)
    at dispatchRequest (dispatchRequest.js?5270:52) 

错误的引入方式

import axios from 'axios'//引入
Vue.use(axios)//使用 正是这种使用方式导致的报错

正确的引入方式

import axios from 'axios'//引入
Vue.prototype.$http = axios //正确的使用

  

上一篇:IDEA 2021 配置Data Sources 报错


下一篇:gRPC