Promise异步加载问题
getOrderList: function(){
var obj=this;//_this
///Order.json/this.orderURL
this.$axios.get(’/Order.json’,{
params:{
accountId:0,
state:1
}
}).then((res)=>{
obj.orderList=res.data;
return Promise.resolve(res)------------------------------//特别注意返回值格式
})
},
//获取保单状态
getPolStateReasonList(){
return this.$axios.get(this.baseURL + ‘/sys/code/findByCodeType?codeType=POL_STATE_REASON’—//特别注意加return
).then((res) => {
let result = res.data;
return Promise.resolve(res)------------------//特别注意返回值格式
// window.console.log(this.polStateReasonList[0].value);
// this.getOrderList()--------------------------------------方法2,也可以通过累加方式-------------------------------
});
},
//通过Promise异步加载数据,先加载码表数据#########################################################设置异步加载
getOrderListData(){
this.getPolStateReasonList().then(val => {
window.console.log(val);
this.getOrderList();
});
}
更多复杂用法可以参考:
https://blog.csdn.net/shan1991fei/article/details/78966297