我正在使用react-bootstrap-table-next(又名react-bootstrap-table2)。我在列定义中的验证器字段上收到了 IntelliJ 中的 Typescript 错误。尽管在沙箱中可以正常工作,但我似乎无法在 IntelliJ 中解决它。就算戴上//@ts-ignore也没用
这是我的列定义:
const columns: ColumnDescription[] = [
{
dataField: 'id',
text: 'Product ID',
headerStyle: () => {
return { width: '20%', textAlign: 'center' };
}
},
{
dataField: 'name',
text: 'Product Name',
sort: true,
headerStyle: () => {
return { width: '60%', textAlign: 'center' };
}
},
{
dataField: 'value',
text: 'Product value',
sort: true,
validator: (newValue, row, column) => {
if (isNaN(newValue)) {
return {
valid: false,
message: 'This field needs to be a number'
};
}
},
headerStyle: () => {
return { width: '20%', textAlign: 'center' };
}
}];
沙盒在这里,它似乎可以工作 https://codesandbox.io/s/table-validator-7ib2n

