weekOfMonth() returns this month and this week(week of this month)
<template>
<h3>{{ weekOfMonth }}</h3>
</template>
<script lang="ts">
export default class HomeView extends Vue {
const moment = require("moment");
private get weekOfMonth(): string {
const nowDate = moment().utc(true);
let week: number = nowDate.week() - moment(nowDate).startOf("month").week() + 1;
return `This Month: ${nowDate.month() + 1} / This Week: ${week}`;
}
}
</script>
result: This Month: 7 / This Week: 4
result when not using 'get' : function () { [native code] }
Why do I have to use getter to get the return value?