Vue 实时显示时间 getNowTime() { setInterval(() => { const date = new Date(); var year = date.getFullYear(); var month = (date.getMonth() + 1).toString().padStart(2, "0"); var day = date.getDate().toString().padStart(2, "0"); var hours = date.getHours().toString().padStart(2, "0"); var minutes = date.getMinutes().toString().padStart(2, "0"); var seconds = date.getSeconds().toString().padStart(2, "0"); this.nowTime = year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds; }, 1000); }, }