[Vue warn]: Error in created hook: "TypeError: Cannot read property 'get' of undefined"
请问我如下这样,为什么发生错误,store里调用不到this.$http的get方法吗?
//main.js
import store from './store'
import axios from 'axios'
import App from './App.vue'
Vue.prototype.$http = axios
//App.vue
created()?{
this.$store.dispatch('allProducts')
},
//store/index.js
actions: {
allProducts()?{
this.$http.get(`http://localhost:3000/login`).
then(response => {console.log(response)}
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…