面板项绘制器脚本
可根据面板数据自定义绘制脚本代码,需返回一段html格式的字符串,绘制面板项时会将返回的字符串以v-html的形式替换掉面板项内容。
参数
| 名称 | 类型 | 描述 |
|---|---|---|
| data | IApiData | 当前业务数据 |
| document | Document | 当前文档对象 |
| selector | (className: string) => HTMLCollectionOf<Element> | 元素选择器 |
| env | IEnvironment | 当前环境对象 |
| appSession | IApiData | 当前应用会话对象 |
| app | IApiAppHubController | 当前应用 |
| util | { message: IApiMessageUtil, notification: IApiNotificationUtil,modal: IApiModalUtil,confirm: IApiConfirmUtil,openView: IApiOpenViewUtil} | 工具集 |
调用示例
基于当前数据绘制自定义标题
typescript
`<h1>${data.title}</hl>`根据数据业务条件绘制面板项内容
使用自执行函数,根据数据中的name判断字体是否红色。
typescript
(function() {
let style = '';
if (data.name === '演示数据1') {
style = `color:red`
} else {
style = `color:blue`
}
return `<div style=${style}>名称-数量:${data.name || ''}-${data.quantity || ''}</div>`;
})()