vue将毫秒为单位的时间转化成分钟和秒
主要应用在前端将音乐时间显示为 00:00( 分钟: 秒格式 )
代码实现
时间戳 = song.duration
分钟
Math.floor((Math.round(时间戳/1000))/60
秒
Math.floor((Math.round(时间戳/1000)) % 60
优化
{{Math.floor((Math.round(song.duration/1000))/60) < 10
? '0' + Math.floor((Math.round(song.duration/1000))/60)
: Math.floor((Math.round(song.duration/1000))/60)}}
:
{{Math.floor((Math.round(song.duration/1000))%60) < 10
? '0' + Math.floor((Math.round(song.duration/1000))%60)
: Math.floor((Math.round(song.duration/1000))%60)}}