index.js
845 字节
export default {
// 秒数转时分秒
seconds(v) {
// 秒
var seconds = v;
// 分
var minutes = 0;
// 小时
var hour = 0;
if (seconds > 60) {
minutes = parseInt(seconds / 60);
seconds = parseInt(seconds % 60);
}
var result;
if (!seconds) {
result = "00"
} else if (seconds < 10 && seconds >= 0) {
result = "0" + parseInt(seconds);
} else {
result = parseInt(seconds);
}
if (minutes > 0 && minutes < 10) {
result = "00:0" + parseInt(minutes) + ":" + result;
} else if (minutes >= 10) {
result = "00:" + parseInt(minutes) + ":" + result;
} else {
result = "00:00:" + result
}
return result
}
}