diff --git a/packages/amis-editor/src/plugin/CRUD.tsx b/packages/amis-editor/src/plugin/CRUD.tsx index bfcb0722c..c858fba53 100644 --- a/packages/amis-editor/src/plugin/CRUD.tsx +++ b/packages/amis-editor/src/plugin/CRUD.tsx @@ -392,7 +392,10 @@ export class CRUDPlugin extends BasePlugin { valueSchema.bulkActions = []; /** 统一api格式 */ - valueSchema.api = typeof valueSchema.api === 'string' ? valueSchema.api : normalizeApi(valueSchema.api); + valueSchema.api = + typeof valueSchema.api === 'string' + ? valueSchema.api + : normalizeApi(valueSchema.api); hasFeatures && features.forEach((item: string) => { if (itemBtns.includes(item)) { @@ -418,7 +421,7 @@ export class CRUDPlugin extends BasePlugin { ); } else if (item === 'delete') { schema = cloneDeep(this.btnSchemas.delete); - schema.api = valueSchema.api?.method.match(/^(post|delete)$/i) + schema.api = valueSchema.api?.method?.match(/^(post|delete)$/i) ? valueSchema.api : {...valueSchema.api, method: 'post'}; } @@ -446,7 +449,7 @@ export class CRUDPlugin extends BasePlugin { const createSchemaBase = this.btnSchemas.create; createSchemaBase.dialog.body = { type: 'form', - api: valueSchema.api?.method.match(/^(post|put)$/i) + api: valueSchema.api?.method?.match(/^(post|put)$/i) ? valueSchema.api : {...valueSchema.api, method: 'post'}, body: valueSchema.columns.map((column: ColumnItem) => {