我先调用了dialogCall()因为接口是异步执行所以先打印dialogCall里的console为空,怎么让它按顺序执行呢,先接口在console
dialogCall() {
this.getUserList();
console.log(this.tableData)//这里为空
},
//接口
getUserList() {
axiosRequestHandler(userModuleUrl.userPage, {
size: 10,
page: 1
}).then(res => {
this.tableData = res.records;
});
},
或者:
或者:
搜索一下
Promise
和async await
用法吧