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.setState({ itemList: <Timeline>{TimelineChild}</Timeline> }) }) }); }
我是用的antd的折叠面板组件,在onChange事件中,我将数据进行遍历放进了数组中,然后渲染出来,现在我想要使用this.setState在刚刚触发onChange事件,还没有开始处理数据之前先将TimelineChild
里面清空一次,该如何做?
用回调啊。
一周热门 更多>