(此文档仅供参考,如何不满足应用场景,需要自行调整相关宏代码)
d问题说明
想实现当无数据的时候,文本组件类似右上角有个小提示,说明:系统数据每月20号更新;有数据就正常展示数据,这个提示语不展示。
解决方案
可以通过宏来处理
/**事件:onAfterRender
组件:文本组件
**/
function main(page: IPage, portlet: IStaticTextPortlet) {
let contentHtml = portlet.getHtmlContent()
let contentText = contentHtml.innerText
if (contentText.replace('测试:', '').length > 0) {
return
}
let tips = document.createElement('p')
tips.innerText = '系统数据每月20号更新' //提示语
tips.style.textAlign = 'right'
tips.style.fontSize = '12px'
contentHtml.insertBefore(tips, contentHtml.children[0])
}