如何在 ant 的table中实现图片的渲染

2 篇文章 0 订阅

如何在 ant 的table中实现图片的渲染
这里写图片描述

在使用react 的蚂蚁金服的ui库的时候,,平时用到的比较比较多的就是table组件,但是在ant官网上面,并没有在后台调取接口获取数据后,,如何将后台的http://lkjlkjlkj.jpg图片渲染到每一行的例子。。只有一个render的方法。。。查阅了一些资料,作为一个不是很资深的前端来说,忙活了一上午,。实现了这个功能。。。记录一下。。。

这里是table的使用

<Table
       selectHandle={false}
       onCtrlClick={ this.tableAction }
       header={this.tableHeader()}
       pagination={ true }
       scroll = {{y:450}}
       pageSize={10}
       getpage={this.getpage}
       currentPage={this.state.currentPage}
       data={this.state.dataSource}
       checkChang={this.checkChang} />

table中theader的渲染

tableHeader = () => {
      return [{
          dataIndex: '',
          title: 'Logo',
          width: 150,
          key : 'image',
          render:(record) => {
                  return <img src={record.image} alt="" style={{width:'5    0px',height:'50px',borderRadius:'50%'}}/>
          }
      },{
          dataIndex: 'name',
          title: '名称',
          width: 150,
          key : 'name'
      },{
          dataIndex: 'label',
          title: '标签',
          width: 150,
          key : 'label'
      },{
          dataIndex: 'collectCount',
          title: '关注数',
          width: 150,
          key : 'collectCount'
      }, {
          dataIndex: 'topicCount',
          title: '帖子数',
          width: 150,
          key : 'topicCount'
      },{
          dataIndex: 'inTime',
          title: '创建时间',
          width: 150,
          key : 'inTime'
      }]
  }

这里写图片描述

利用table 中 render的属性,,,将LOGO在tableHeader中render return一个img 标签,并将src={ record.image }
图片就正确的渲染到你的table中了。。拿走 不谢~~~

评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值