diff --git a/packages/amis-core/src/store/table2.ts b/packages/amis-core/src/store/table2.ts index 2464b0174..d4aa5c959 100644 --- a/packages/amis-core/src/store/table2.ts +++ b/packages/amis-core/src/store/table2.ts @@ -442,7 +442,7 @@ export const TableStore2 = ServiceStore.named('TableStore2') function exchange(fromIndex: number, toIndex: number, item?: IRow2) { item = item || self.rows[fromIndex]; - if (item.parentId) { + if (item?.parentId) { const parent: IRow2 = self.getRowById(item.parentId) as any; const offset = parent.children.indexOf(item) - fromIndex; toIndex += offset; diff --git a/packages/amis/src/renderers/Table2/index.tsx b/packages/amis/src/renderers/Table2/index.tsx index 81c9a72c6..14c7bda22 100644 --- a/packages/amis/src/renderers/Table2/index.tsx +++ b/packages/amis/src/renderers/Table2/index.tsx @@ -1591,11 +1591,13 @@ export default class Table2 extends React.Component { if (rowClassNameExpr) { classnames.push(filter(rowClassNameExpr, {record, rowIndex})); } + // row可能不存在 + // 比如初始化给了10条数据,异步接口又替换成4条 const row = store.getRowByIndex(rowIndex); - if (row.modified) { + if (row?.modified) { classnames.push('is-modified'); } - if (row.moved) { + if (row?.moved) { classnames.push('is-moved'); } return classnames.join(' ');