1. 程式人生 > >react常見問題(三)

react常見問題(三)

action lis 名稱 stat tex substring str turn etl

表格相關

<Table dataSource={data} className="mt1" columns={columns} pagination={pagination}  rowKey={record => record.city_id}/>
const columns = [{
      title: ‘學校名稱‘,
      dataIndex: ‘school_name‘,
      key: ‘school_name‘,
      render:(text,record)=>{
        if(text!=null){
          
return (<span title={text}>{text.length>15?text.substring(0,15)+‘...‘:text}</span>) } } }]
var page = {
      onChange: (index) => {
        var params={
          pageIndex: index,
          pageSize: 10,
          filter: {
            city_code: this.state.cityCode,
            school_name: this.state.schoolName
        }};
        this.props.dispatch(actions.getlList(params));
      },
      total: parseInt(count),
      showTotal: (total) => {
        return `共 ${count} 條`
      },
      showQuickJumper: false,
      showSizeChanger: false,
    }

表格中的key不允許有空格,dataIndex屬性為必須,確保datasource為數組形式

react常見問題(三)