vue2.0倒计时

前端之家收集整理的这篇文章主要介绍了vue2.0倒计时前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

vue2.0倒计时,vue2.0 js 倒计时,vue倒计时

Meta charset="UTF-8">
    方法体
        methods:
        {
            num: function (n) {
                return n < 10 ? '0' + n : '' + n
            },            timeToData:function ( maxtime ) {
                second = Math.floor( maxtime % 60);       //计算秒
                minite = Math.floor((maxtime / 60) % 60); //计算分
                hour = Math.floor((maxtime / 3600) % 24 ); //计算小时
                day = Math.floor((maxtime / 3600) / 24);//计算天
                return day+'天'+this.num(hour)+'时'+this.num(minite)+'分'+this.num(second)+'秒';
            },            getTime:function () {
                var that = this;
                setInterval(function ()
                {
                    that.list.forEach(function (value) {
                        var shijian = that.timeToData(value.time);
                        if( typeof value.jishi == 'undefined' )
                        {
                            that.$set(value,'jishi',shijian);
                        }else
                        {
                            value.jishi = shijian;
                        }
                        if( value.time )
                        {
                            -- value.time;
                        }else
                        {
                            value.time = 0;
                        }
                    })
                }, 1000);
            }
        },        //页面打开渲染之前就调用
        created: function () {
            var that = this;
            that.getTime();
        }
    });



猜你在找的jQuery相关文章