美文网首页
vue获取当前日期时间的方法

vue获取当前日期时间的方法

作者: 吃肉肉不吃肉肉 | 来源:发表于2020-11-05 09:21 被阅读0次
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
    
    },
}

相关文章

网友评论

      本文标题:vue获取当前日期时间的方法

      本文链接:https://www.haomeiwen.com/subject/hclovktx.html