0
点赞
收藏
分享

微信扫一扫

vue js获取当天日期

90哦吼 2023-10-15 阅读 36


<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>


举报

相关推荐

0 条评论