vue 如何把秒转换为时间格式
this.pages = res.pages;
this.listTableLoading = false;console.log(this.tableOperationList,"行为审计")
if(timeEvents.length){
let timeEvent=[];
//把传输时长添加到数组里
timeEvents.forEach((vo) => {
timeEvent.push(vo.pushStreamHowlong)
});
}
如何把数组的时长秒数转换成00:00:00这种时间格式
回答
const fomatSecond = (time) => { const push0 = str => str<=9?'0'+str:str;
return `${push0(parseInt(time/60/60))}:${push0(parseInt(time/60%60))}:${push0(time%(60))} `
}
function formatTime(second) { function padStart(num) {
return (num|0).toString().padStart(2,'0')
}
return padStart(second/60/60)+':'+padStart(second/60%60)+':'+padStart(second%60)
}
<div>{{parseLen(parseInt(scope.row.pushStreamHowlong/60/60))}}:{{parseLen(parseInt(scope.row.pushStreamHowlong/60%60))}}:{{parseLen(parseInt(scope.row.pushStreamHowlong%60))}}</div>
//时间格式转换补0
parseLen(v){ return v>9 ?v:"0"+v;
},
谢谢两位老哥。自己学习了
以上是 vue 如何把秒转换为时间格式 的全部内容, 来源链接: utcz.com/a/80665.html