<style>
/* 定义css全局变量*/
:root{ --displays: none; }
</style>
<script type="text/javascript">
//获取登陆用户角色信息
var exports = ‘@{biServer.variables[‘NQ_SESSION.ROLES‘]}‘;
//判断用户角色中包含指定角色代码,并设置css变量值
if(exports.indexOf("hh")!=-1){
document.documentElement.style.setProperty(‘--displays‘, ‘inline‘);
}else {
document.documentElement.style.setProperty(‘--displays‘, ‘none‘);
}
alert(getComputedStyle(document.documentElement).getPropertyValue(‘--displays‘));
</script>
<style>
/*读取css全局变量*/
[name=ReportLinkMenu]{display:var(--displays);}
</style>
原文:https://www.cnblogs.com/cn1024/p/14870811.html