今天开发遇到2个坑:
1.antd 2.0 的版本table的前面复选框 disabled不生效?
踩坑原因:选用的antd版本不对,antd 2.0版本不需要props
getCheckboxProps: (record: any) => ({
disabled: record.name === 'Disabled User', // Column configuration not to be checked
name: record.name,
}),
而antd 1.7 是这样的:
getCheckboxProps: (record: any) => ({
props:{
disabled: record.name === 'Disabled User', // Column configuration not to be checked
name: record.name,
}
}),
2.table的点击行与点击复选框:2中操作选择row,导致的selectrowkey不一样?
bug原因分析:在antd table组件中,我写table属性 row-selection = rowSelection 这个对象里面。
这导致在执行changeRow时,this指向vue实例和我点击行拿到的this:vue实例不同。
const rowSelection = {
onChange: changeRow
getCheckboxProps: (record: DataType) => ({
disabled: record.name === 'Disabled User',
}),
};