react常见问题
Posted 小金鱼紫苏
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了react常见问题相关的知识,希望对你有一定的参考价值。
表格相关
<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常见问题的主要内容,如果未能解决你的问题,请参考以下文章
[react] Module not found: Can't resolve 'schedule' in 'C:Usersadcaldvmtn7myapp (代码片段
[React Testing] Use Generated Data in Tests with tests-data-bot to Improve Test Maintainability(代码片段