vue dayjs 日期星期格式化

vue yekong
/**
* @Author: 858834013@qq.com
* @Name: dayTime
* @Date: 2022-05-31
* @Desc: dayTime Week
*/
<template>
  <div>
    {{ time }} <span>星期{{ week }}</span>
  </div>
</template>

<script>
import dayjs from 'dayjs'

export default {
  name: "dayTime",
  components: {dayjs},
  data() {
    return {
      time: dayjs().format("YYYY-MM-DD HH:mm:ss")
    }
  },
  computed: {
    week() {
      var datas = dayjs().day()
      var week = ['日', '一', '二', '三', '四', '五', '六']
      return week[datas]
    }
  },
  watch: {},
  mounted() {
    var that = this;
    setInterval(function () {
      that.time = dayjs().format("YYYY-MM-DD HH:mm:ss");
    }, 1000);
  },
  methods: {}
}
</script>

<style lang="scss" scoped>

</style>

喜欢