简体中文
getDescribe
约 338 字大约 1 分钟
2025-12-16
dataGetter.getDescribe() 用于获取当前对象的对象描述。
用途
获取当前对象的对象描述
函数签名
context.dataGetter.getDescribe()参数
无。
返回值
Object | null
返回当前对象描述的深拷贝。修改返回对象不会直接修改详情页内部描述;对象描述尚未就绪时返回null。
| 参数 | 说明 | 类型 | 默认值 |
|---|---|---|---|
| api_name | 对象apiName | String | -- |
| display_name | 对象显示名称 | String | -- |
| fields | 以字段apiName为key的对象字段描述数据 | Object | -- |
fields[fieldApiName]
字段描述会随字段类型包含不同属性,以下是生成字段读取代码时常用的稳定或可选属性。
| 参数 | 说明 | 类型 | 默认值 |
|---|---|---|---|
| api_name | 字段apiName | String | -- |
| display_name | 字段显示名称 | String | -- |
| type | 字段类型 | String | -- |
| return_type | 字段返回类型;部分字段不存在 | String | -- |
| options | 单选、多选等字段的选项;非选项型字段可能不存在 | Object[] | -- |
| target_api_name | 关联字段指向的对象apiName;非关联字段不存在 | String | -- |
基础示例
let { dataGetter } = context;
if (typeof dataGetter === 'function') {
dataGetter = dataGetter();
}
const objDescribe = dataGetter.getDescribe();
if (objDescribe) {
console.log(objDescribe);
console.log(objDescribe.fields.name);
}注意事项
2. 返回值是深拷贝,字段描述属性会随字段类型变化。生成代码前应先判断可选属性是否存在。
