page1columns = [{ title: '操作', dataIndex: 'action', fixed: 'right', width: 76, render: [ { title: '编辑', icon: 'edit', span: 12, onClick: 'this.showEdit.bind(this, record)', }, { title: '删除', icon: 'delete', span: 12, onClick: 'this.delectItem.bind(this, record)', }, ],},,,,]page2handleColumns = (columns) => { columns.forEach((item, index) => { if (item.dataIndex == 'action') { item['render'] = (text, record) => ( <Row type="flex" justify="space-between" align="middle" gutter={8} style={{ width: item.width }}> {item.other.map((item, index) => { return <Col key={index} span={item.span}><Tooltip title={item.title}><Button shape="circle" icon={item.icon} /></Tooltip></Col> })} </Row> ) } }) return columns}<Table columns={handleColumns(columns)}/>如果换成jsx语法,因为不在一个页面,函数会在page1执行,因为this指向的是page1
2 回答
炎炎设计
TA贡献1808条经验 获得超4个赞
不要用 bind 或箭头函数不就好了。onClick = {this.showEdit}
还有,你最上面 page1里的,onClick: 'this.showEdit.bind(this, record)' 是错的,首先onclick 的值是个字符串,根本不是方法,其次,bind 用法也错误。
添加回答
举报
0/150
提交
取消
