vue js获取当天日期

<template>
  <div>
    <p>Today is {{ today }}</p>
  </div>
</template>

<script>
export default {
  data() {
    return {
      today: ''
    }
  },
  mounted() {
    this.today = this.getCurrentDate();
  },
  methods: {
    getCurrentDate() {
      let now = new Date();
      let year = now.getFullYear();
      let month = now.getMonth() + 1;
      let day = now.getDate();
      return year + "-" + month + "-" + day;
    }
  }
}
</script>

你可能感兴趣的:(时间处理,javascript,vue.js,前端)