{ title: "持续时长", key: "alarmDuration", align: "center", minwidth: 100, render: (h, params) => { var theTime = params.row.alarmDuration; // 秒 var middle = 0; // 分 var hour = 0; // 小时 if (theTime > 60) { middle = parseInt(theTime / 60); theTime = parseInt(theTime % 60); if (middle > 60) { hour = parseInt(middle / 60); middle = parseInt(middle % 60); } } var result = "" + parseInt(theTime) + "秒"; if (middle > 0) { result = "" + parseInt(middle) + "分" + result; } if (hour > 0) { result = "" + parseInt(hour) + "小时" + result; } return h("span", result); } },
parseInt() 函数可解析一个字符串,并返回一个整数