我在main.js中创建了Axios Instance Properties:
import Axios from "axios";
const axios = Axios.create({
baseURL: process.env.VUE_APP_BASE_URL
})
Vue.prototype.$http = axios;
我可以在Vue实例中使用它,但是如何在store.js
中使用它,这是一个vuex
商店?
找不到this.$http
。
TypeError: _this.$http is not a function
我得到了答案:
Use Vue.prototype.$http
您可以导入Vue
来使用它。
import Vue from 'vue'
async action() {
const response = Vue.http.get('api/users');
}