简体中文
通用参数
约 280 字小于 1 分钟
2025-12-16
对象详情插件通用参数说明如下。
对象详情Hook的functional回调会依次接收context和plugin两个参数。事件专属参数会直接合并到context顶层,具体字段以对应事件文档为准。
| 参数 | 说明 | 类型 |
|---|---|---|
| context | 详情插件上下文,包含通用参数和事件专属参数 | Object |
| plugin | 当前插件运行信息,业务逻辑通常不需要使用 | Object |
| context.objectApiName | 当前详情对象apiName | String |
| context.objectDataId | 当前详情对象数据ID | String |
| context.bizApi | 详情业务操作方法,详见bizApi | Object |
| context.dataGetter | 数据获取API,详见dataGetter;当前为挂载了API方法的可调用函数 | Function |
注意事项
1. dataGetter使用请进行类型判断
由于dataGetter早期设计时未遵循规范,当前运行时是挂载了API方法的可调用函数。为了兼容后续可能的规范调整,请统一使用以下类型判断写法。
export default class Plugin {
apply() {
return [{
event: 'detail.render.before',
functional: this.renderBefore.bind(this)
}]
}
renderBefore(context, plugin) {
let { dataGetter } = context;
if (typeof dataGetter === 'function') {
dataGetter = dataGetter();
}
dataGetter.getDescribe();
}
}