岁月展现效果代码,Vue中倒计时的做法

岁月展现效果代码,Vue中倒计时的做法。项目要求做一个试验倒计时的作用,参考了CSDN上的3次博文美高梅开户网址,,做出自个儿的功能,在此多谢sinat_17775997
“`

复制代码 代码如下:

复制代码 代码如下:

<el-button type=”text” v-text=”keepTime”
@click=”StartCountDown”>

function settime()
{
var myyear,mymonth,myweek,myday,mytime,mymin,myhour,mysec;
var mydate=new Date();
myyear=mydate.getFullYear();
mymonth=mydate.getMonth();
myday=mydate.getDate();
myhour=mydate.getHours();
mymin=mydate.getMinutes();
mysec=mydate.getSeconds();
mytime=”今天是:”+myyear+”年”+mymonth+”月”+myday+”日”+myhour+”:”+mymin+”:”+mysec;
document.getElementById(‘xwgtime’).innerHTML=mytime;
setTimeout(‘settime()’,1000);
}

function settime()
{
var myyear,mymonth,myweek,myday,mytime,mymin,myhour,mysec;
var mydate=new Date();
myyear=mydate.getFullYear();
mymonth=mydate.getMonth();
myday=mydate.getDate();
myhour=mydate.getHours();
mymin=mydate.getMinutes();
mysec=mydate.getSeconds();
mytime=”今天是:”+myyear+”年”+mymonth+”月”+myday+”日”+myhour+”:”+mymin+”:”+mysec;
document.getElementById(‘xwgtime’).innerHTML=mytime;
setTimeout(‘settime()’,1000);
}

export default {
data() {
return {
keepTime: ‘倒计时’,
limittime:100,
settime: ”,
flag: false
}
},
methods: {
StartCountDown() {
var mydate = new Date();
mydate.setMinutes(mydate.getMinutes() + this.limittime);
this.settime=mydate;

那般就会显得时间了!脚本真的很庞大。。。!用该格局也得以做出网址过几少后自个儿转变来时另三个页面去的作用!
例如:

那样就能够展现时间了!脚本真的很强劲。。。!用该措施也足以做出网址过几少后自个儿转变来时另1个页面去的功力!
例如:

        let time = setInterval(() => {
            if (this.flag == true) {
                clearInterval(time)
            }
            this.timeDown()
        }, 100)
    },
    timeDown() {
        const endTime = new Date(this.settime);
        const nowTime = new Date();
        let leftTime = parseInt((endTime.getTime() - nowTime.getTime()) / 1000);
        let d = parseInt(leftTime / (24 * 60 * 60));
        let h = this.formate(parseInt(leftTime / (60 * 60) % 24));
        let m = this.formate(parseInt(leftTime / 60 % 60));
        let s = this.formate(parseInt(leftTime % 60));
        if (leftTime <= 0) {
            this.flag = true;
            alert("时间到,停止作答");
        }
        this.keepTime = `${h}:${m}:${s}`;
    },
    formate(time) {
        if (time >= 10) {
            return time
        } else {
            return `0${time}`
        }
    },

复制代码 代码如下:

复制代码 代码如下:

}

function SetTime(NomeTime)
{
document.getElementById(“TimeValue”).innerHTML=NomeTime+”秒后活动登6″;
NomeTime–;
if(NomeTime==-1)
{
document.getElementById(“TimeValue”).style.display=”none”;
return;
}
window.setTimeout(“javascript:SetTime(“+NomeTime+”)”,1000);
}

function SetTime(NomeTime)
{
document.getElementById(“TimeValue”).innerHTML=NomeTime+”秒后活动登入”;
NomeTime–;
if(NomeTime==-1)
{
document.getElementById(“TimeValue”).style.display=”none”;
return;
}
window.setTimeout(“javascript:SetTime(“+NomeTime+”)”,1000);
}

里头Nome提姆e为开首时间大小比方10秒!

在这之中NomeTime为开首时间大小举个例子10秒!

代码如下: function settime() { var
myyear,mymonth,myweek,myday,mytime,mymin,myhour,mysec; var mydate=new
Date(); myyear=mydate.getFullYear(); mymonth=mydate.getMon…

你大概感兴趣的文章:

  • js显示动态时间的艺术详解
  • JavaScript落实同台于地面时间的动态时间展现格局
  • javascript页面上应用动态时间具体贯彻
  • 纯JS达成动态时间展现代码
  • 仅贰行代码的javascript按钦命格式展现日期时间效果
  • js双色时间效果代码
  • JS、jquery达成几分钟前、几小时前、几天前等日子差显示效果的代码实例分享
  • js图片滚动作效果应时间可随便设定当鼠标移上去时停下
  • js达成动态突显时间效果

发表评论

电子邮件地址不会被公开。 必填项已用*标注

网站地图xml地图