Small knowledge, big challenge! This article is participating in the creation activity of “Essential Tips for Programmers”.
preface
Eat enough to write code
Today when the fish wanted to celebrate the mother of the motherland, so began to write a National Day countdown, now share to you ~
Routing hop
configuration
This place is stuck for a long time because it is not configured when building a VUE project with CMD. Here are some points to note:
Properly configured, the project structure will have routing-related code
Countdown code
teasing
This place has to poke fun at Internet Explorer, absolutely! The graph below is a log of my browser debugging. I’ve run this code 800 times in the company, all in Chrome, and nothing like this ever happens! Const t = new Date(“Oct 1, 2021 00:00:00”); That line, but that’s fine on Chrome!
The core code
Created (){setInterval(this.timedown, 1000); created(){setInterval(this.timedown, 1000); }, this line of code;
mounted(){
this.timeDown();
},
created(){
setInterval(this.timeDown, 1000);
},
methods: {
timeDown: function(){
console.log("What's going on?")
const t = new Date("Oct 1, 2021 00:00:00");
const now = new Date(a);const des = t.getTime() - now.getTime();
const days = Math.floor(des / (1000 * 60 * 60 * 24));
const hours = Math.floor(
(des % (1000 * 60 * 60 * 24))/(1000 * 60 * 60));const mins = Math.floor((des % (1000 * 60 * 60))/(1000 * 60));
const secs = Math.floor((des % (1000 * 60)) / 1000);
this.day = days;
this.hour = hours;
this.minute = mins;
this.seconds = secs; }},Copy the code
You can modify the style to make it more beautiful, here is just an idea!
Add a flag background, the atmosphere group has to get up ~