代码
filters:{currentTimeformat: function(value) {if (!value) return '00:00'
let interval = Math.floor(value)
let minute = (Math.floor(interval / 60)).toString().padStart(2, '0')
let second = (interval % 60).toString().padStart(2, '0')
return `${minute}:${second}`
}
},
应用
<p class="pro_time"><span>{{this.audioObj.currentTime | currentTimeformat}}</span>/{{this.audioObj.duration | currentTimeformat}}</p>
要点:
Math.floor(工夫戳)向下取整
.toString().padStart(2, '0') 字符串主动补全