Countdown(){var today = new Date(); //当前的时间var endTime = new Date('2022-01-01');//指定的结束时间var interval = endTime.getTime() - today.getTime();var day = Math.floor(interval / (1000 * 60 * 60 * 24));var hour = Math.floor(interval / (1000 * 60 * 60) % 24);var min = Math.floor(interval / (1000 * 60) % 60);var sec = Math.floor(interval / 1000 % 60);if(day < 10) {day = "0" + day;}if(hour < 10) {hour = "0" + hour;}if(min < 10) {min = "0" + min;}if(sec < 10) {sec = "0" + sec;}this.days = day;this.hours = hour;this.minutes = min;this.seconds = sec; },
mounted(){setInterval(()=>{this.Countdown()console.log("执行了没 定时器")},1000)},
在函数data里面写这几个变量 days hours minutes seconds