为了账号安全,请及时绑定邮箱和手机立即绑定

Antd Column 渲染异步函数

Antd Column 渲染异步函数

胡说叔叔 2023-04-01 15:55:33
我试图通过名为func1的异步函数通过列的渲染属性填充 Antd 表中的列(不在数据中):... o.render = (text, record) => (<Progress percent = { func1.then((res)=> {return res} ) />) ...问题不是显示异步函数的返回值,而是显示[object Promise].我怎样才能从中提取正确的值并准确显示?任何指针赞赏..
查看完整描述

1 回答

?
开心每一天1111

TA贡献1836条经验 获得超13个赞

在没有任何上下文的情况下,可能的解决方案可能如下所示:


o.render = (text, record) => (

  <RowComp text={text} record={record} promise={func1} />

);


const RowComp = ({ promise, ...props }) => {

  useEffect(async () => {

    const res = await promise;

    setResult(res);

  }, []);

  ...

};


查看完整回答
反对 回复 2023-04-01
  • 1 回答
  • 0 关注
  • 94 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信