如下
new Date().getTime()
獲取當前時間(毫秒)
我需要對比的時間為秒,所以需要除於1000
<div v-if="scope.row.created_at < new Date().getTime()/1000">
我小於當前時間,所以會顯示出來
</div>
獲取當前日期時間
data(){
return{
updateTime:""
}
},
methods:{
//獲取當前年月日
addDate(){
const nowDate = new Date();
const date = {
year: nowDate.getFullYear(),
month: nowDate.getMonth() + 1,
date: nowDate.getDate(),
}
const newmonth = date.month>10?date.month:'0'+date.month
const day = date.date>10?date.date:'0'+date.date
this.updateTime = date.year + '-' + newmonth + '-' + day
},
}