项目入口文件
app.vue
<script>
.....
create() {
const that = this;
that.$store.dispatch('Getsiteinfoactions');
console.log(that.$store.state.siteinfo);
...........
在VUEX中Getsiteinfoactions是调用接口给siteinfo进行赋值
actions:{
Getsiteinfoactions(context){
axios.get('/api/wapinfo/index').then(response => {
context.commit("Getsiteinfomutations",response.data.data);
})
},
axios是一个异步,导致不能及时的把请求到的值赋给siteinfo
有什么办法可以解决这个问题吗?