<div class="dateAndSelect" >
<p>日期: {
{yearMD}} {
{Hms}}</p>
</div>
data() {
return{
yearMD:'',
Hms:'',
selectDate:'',
}
},
mounted(){
let that = this;
//定时器
setInterval(()=>{
that.getDateFunc();
},1000)
},
methods:{
getDateFunc(){
let year = new Date().getFullYear();//年
let month = new Date().getMonth() +1;//注意!月份是从0月开始获取的,所以要+1;
let day = new Date().getDate();//日
let hour = new Date().getHours();//时
let minute = new Date().getMinutes();//分
let second = new Date().getSeconds();//秒
//拼接日期 YYYY-MM-DD HH:mm:ss
this.yearMD =
year +
'-' +
(month >=10 ? month:'0'+ month) +
'