1000毫秒转换成“0:01.000”格式的毫秒

formatTime(msTime) {
                let time = msTime / 1000;
                let minute = (Math.floor(time / 60) % 60) > 9 ? (Math.floor(time / 60) % 60) : '0' + (Math.floor(time / 60) % 60);
                let second = (Math.floor(time) % 60) > 9 ? (Math.floor(time) % 60) : '0' + (Math.floor(time) % 60);
                let waitTime = '';
                if ((msTime % 1000 > 9) && (msTime % 1000 < 99)) {
                    waitTime = '0' + msTime % 1000
                } else if (msTime % 1000 < 10) {
                    waitTime = '00' + msTime % 1000
                } else {
                    waitTime = msTime % 1000
                }
                return `${minute}:${second}.${waitTime}`

            }
this.formatTime(1000)
 

 

上一篇:原生js之随机n,m之间的整数的封装


下一篇:2021-02-27js学习-对象,数组,math