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)}}
本文详细解析如何使用Vue前端框架将歌曲时间戳转换为易读的分钟:秒格式,提供代码优化示例,助您快速理解并应用于实际项目中。
734

被折叠的 条评论
为什么被折叠?



