优艾设计网

react 因为this.setState是异步生效的,我想要通过this.setState来赋予控 财富值43?

优艾设计网 https://www.uibq.com 2023-04-24 18:27 出处:网络 作者:PS教程自学
onChange(key) { let detailData = []; let TimelineChild = []; const orderCodeData = { orderCode: key, }; const self = this; self.setState({ itemList:[], }) callGetDetailLogMemoFn(orderCodeData).then((r

onChange(key) { let detailData = []; let TimelineChild = []; const orderCodeData = { orderCode: key, }; const self = this; self.setState({ itemList:[], }) callGetDetailLogMemoFn(orderCodeData).then((res) => { detailData = res.data; detailData.map((item) => { const detailDataGmtCreate = item.gmtCreate; const detailDataLogMemo = item.logMemo; const reg = /u5931u8D25/g; const regBeyond = /u8d85u65f6/g; const regs = reg.test(detailDataLogMemo); const regBeyonds = regBeyond.test(detailDataLogMemo); if (regs || regBeyonds) { if (detailDataLogMemo !== null && detailDataLogMemo.length >= 64) { TimelineChild.push( <Timeline.Item color="red" key={item.id}> {detailDataGmtCreate} - {detailDataLogMemo.substring(0, 50)} <Button type="primary" size="small" onClick={this.handleDetail.bind(this, detailDataLogMemo)}>详情</Button> </Timeline.Item> ) } else { TimelineChild.push( <Tooltip placement="topRight" arrowPointAtCenter key={item.id} title={detailDataLogMemo}> <Timeline.Item color="red" key={item.id}> {detailDataGmtCreate} - {detailDataLogMemo.substring(0, 50)} </Timeline.Item> </Tooltip> ) } } else { if (detailDataLogMemo !== null && detailDataLogMemo.length >= 64) { TimelineChild.push( <Timeline.Item key={item.id}> {detailDataGmtCreate} - {detailDataLogMemo.substring(0, 50)} <Button type="primary" size="small" onClick={this.handleDetail.bind(this, detailDataLogMemo)}>详情</Button> </Timeline.Item> ) } else { TimelineChild.push( <Tooltip placement="topRight" arrowPointAtCenter key={item.id} title={detailDataLogMemo}> <Timeline.Item key={item.id}> {detailDataGmtCreate} - {detailDataLogMemo.substring(0, 50)} </Timeline.Item> </Tooltip> ) } } self.se优艾设计网_PS百科tState({ itemList: <Timeline>{TimelineChild}</Timeline> }) }) }); }

我是用的antd的折叠面板组件,在onChange事件中,我将数据进行遍历放进了数组中,然后渲染出来,现在我想要使用this.setState在刚刚触发onChange事件,还没有开始处理数据之前先将TimelineChild里面清空一次,该如何做?


嘴角那抹冷笑 优艾设计网_设计客 2022-09-14 08:12

用回调啊。


0

精彩评论

暂无评论...
验证码 换一张
取 消