LayUI 使用公共枚举
1 创建公共枚举 enumFunction.js
/**
* 逾期状态 0未逾期 1已逾期
*/
function overdueStatus(d) {
if(d ===null || d === '' ){
return null;
}
else if(d === 0)
return "未逾期";
else if( d ===1){
return "已逾期";
} else {
return "不存在的类型"
}
}
2 在html 中引入枚举 purchaseRepayFlowList.html
<script th:src="@{/modules/enumFunction.js}"></script>
<script>
layui.config({
base: '/' //静态资源所在路径
}).extend({
index: 'lib/index' //主入口模块
,purchaseRepayFlowList: '/repayment/purchaseRepayFlowList'
}).use(['index','purchaseRepayFlowList']);
</script>
3 在模块中使用枚举 purchaseRepayFlowList.js
, {field: 'overdueStatus', title: '逾期状态', align: 'center', minWidth: 100,
templet: function (d) {return overdueStatus(d.overdueStatus);}}
通过知识/经验的分享,节省开发者的时间.

浙公网安备 33010602011771号