获取当前日期,格式如:2021-07-02

getDate () {
      this.$nextTick(() => {
        const now = new Date()
        const year = now.getFullYear() // 得到年份
        let month = now.getMonth() // 得到月份
        let date = now.getDate() // 得到日期
        month = month + 1
        month = month.toString().padStart(2, '0')
        date = date.toString().padStart(2, '0')
        const defaultDate = `${year}-${month}-${date}`
        this.$set(this.modifyDialog.form, 'presentDate', defaultDate)
      })
    } //获取当前日期,格式如:2021-07-02

 

posted @ 2021-07-31 10:30  Hakuna__Matata  阅读(65)  评论(0编辑  收藏  举报