In main.js you can just assign Axios to $http.
main.js
import Axios from 'axios'
Vue.prototype.$http = Axios;
By modifying the vue prototype, any vue instance will have the ability to call $http
on this
. (e.g. this.$http.get('https://httpbin.org/get')
Note: $http
is the axios object now, so any method you can call on axios object, you can call on this.$http
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…