react 遍历生成不同区块下的内容

// 存储变量

@observable detail= {};

// 请求接口

@action

async searchD(sysId, obj) {

this.statisticLoading = true;      // loading 以防异步加载渲染时数据还没取到

try {

    const res = await ApiService.searchDtail(obj);

   runInAction(() => {

      if (res && res.size > 0) {

        this.detail[sysId] = res.list;   // 防止点击其他模块时内容被篡改

    }

   this.statisticLoading = false;

});

} catch (error) {

  this.statisticLoading = false;

  console.log(error);

}

}

// 渲染

expandContent = record => {

const { detail} = this.store;

return (

<div>

{detail!== '' && detail[record.sysId] !== undefined    // 根据不同ID渲染

&& detail[record.sysId].length > 0 ?

detail[record.sysId].map((item) => {

return (

<Row key={record.sysId}>

<Col span={4}>{item.createDate}</Col>

{

item.alarmLevel === '1' &&

<Col span={4}>

<div className={cx('icon')} style={{ backgroundColor: '#F5222D' }} />

致命

</Col>

}

{

item.alarmLevel === '2' &&

<Col span={4}>

<div className={cx('icon')} style={{ backgroundColor: '#FAAD14' }} />

严重</Col>

}

{

item.alarmLevel === '3' &&

<Col span={4}>

<div className={cx('icon')} style={{ backgroundColor: '#F8E71C' }} />

一般</Col>

}

<Col span={14}>{item.alarmTitle}</Col>

<Col span={2}>

     ......

</Col>

</Row>

);

})

: ''}

</div>

);

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值