const { result } = await getByid(id);
// 创建一个新对象,包含除bbsj之外的所有字段
const filteredForm = Object.fromEntries(
Object.entries(result.entity).filter(([key, value]) => key !== 'Timedate')
);
state.form = filteredForm;
这段代码首先等待getByid异步请求完成并从中提取result
。接着,使用Object.entries
将result.
entity 对象转为键值对数组。然后,使用filter
方法过滤出不含timedate
键的键值对。最后,使用Object.fromEntries
将过滤后的键值对数组还原为一个新对象,并将其赋值给state.form
。
这样,state.form
将包含result.
entity 中除timedate
字段外的所有字段。