我在代码库中偶然发现了这个错误,并试图看看是否有人可以修复它。
以下是我的listings/actions.js
export const fetchFeaturedListings = ({ commit }) => {
this.$axios.get("/featured").then(response => {
console.log(response.data.data);
commit("listings/setFeaturedListings", response.data.data);
});
};
Run Code Online (Sandbox Code Playgroud)
我不断收到以下错误。
无法读取未定义的属性“$axios”
我到处寻找,仍然找不到答案。希望有人能帮忙。
小智 5
对于箭头函数 vuex 无法设置“this”。尝试使用标准函数。
export const fetchFeaturedListings = function({ commit }){
this.$axios.get("/featured").then(response => {
console.log(response.data.data);
commit("listings/setFeaturedListings", response.data.data);
});
};
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6806 次 |
| 最近记录: |