React点击一次按钮能获取到数据但是却无法显示到页面上
onExpand=(expanded,record)=>{console.log(record)letdesipertion;functionexpand(){retur...
onExpand = (expanded, record) => {
console.log(record)
let desipertion;
function expand() {
return new Promise((resolve, reject) => {
window.rpc.task.device.getArrayBriefByContainer({ id: record.id }, 0, 0).then((res) => {
resolve();
desipertion = res.map(x => ({ ...x, key: x.id, setupTime: moment(x.createTime).format('YYYY-MM-DD'), type: x.typeName }));
})
})
}
async function execute() {
await expand();
record.desipertion = desipertion;
console.log(record.desipertion)
}
execute();
}
这里我点击会触发这个函数,能获取到record.desipertion数据,但是无法显示到页面上,要我点击第二次才能显示上一次的数据,这里我用了ant design框架写的
求大神解释~~在线等!! 展开
console.log(record)
let desipertion;
function expand() {
return new Promise((resolve, reject) => {
window.rpc.task.device.getArrayBriefByContainer({ id: record.id }, 0, 0).then((res) => {
resolve();
desipertion = res.map(x => ({ ...x, key: x.id, setupTime: moment(x.createTime).format('YYYY-MM-DD'), type: x.typeName }));
})
})
}
async function execute() {
await expand();
record.desipertion = desipertion;
console.log(record.desipertion)
}
execute();
}
这里我点击会触发这个函数,能获取到record.desipertion数据,但是无法显示到页面上,要我点击第二次才能显示上一次的数据,这里我用了ant design框架写的
求大神解释~~在线等!! 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询