layui table 时间格式转换、根据数据转换为提示信息
<script type="text/javascript"> layui.use("table", function (table) { //展示已知数据 t = table.render({ cols: [[ //标题栏 { field: 'NOA_NPCode', title: '产品', align: 'center', sort: true }, { field: 'NOA_Count', title: '剩余次数', align: 'center', sort: true }, { field: 'NOA_ExpireTime', title: '到期时间', align: 'center', sort: true, templet: '<div>{{ layui.util.toDateString(d.NOA_ExpireTime, "yyyy年MM月dd日") }}</div>'}, { field: 'operate', title: '操作', 150, toolbar: '#barTable', align: 'center' } ]], elem:'#idforRenderElem', url: '@Url.Action("GetAccountList")', page: false, response: { statusName: 'Code', statusCode: 1, dataName: 'Data' }, done: function (res, curr, count) { $("[data-field='NOA_Count']").children().each(function () { if ($(this).text() == '-1') { $(this).text("不限次") } }); } }); //监听工具条 table.on('tool(layFilterTable)', function (obj) { if (obj.event === 'edit') { //页面层 AddOrEdit(obj); } }); }); //点击刷新按钮 $('#btnRefresh').click(function () { t.reload(); }); </script>