function debounce(func: any, delay: any) {
let timer: any = null;
return function () {
if (timer) {
clearTimeout(timer);
timer = null;
}
timer = setTimeout(() => {
func(...arguments);
}, delay);
};
}
debounce(this.isClear(val),1000) // 参数1:需要防抖触发的函数 参数2:防抖的时间
时间戳转年月日时分秒
function timestampToTime(timestamp: any) {
var date = new Date(timestamp);
var year = date.getFullYear();
var month = date.getMonth() + 1;
var day = date.getDate();
var hours = date.getHours();
var minutes = date.getMinutes();
var seconds = date.getSeconds();
return year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds;
}