效果

在utils文件夹下创建format_date.js文件
import dayjs from "dayjs";
export function formatMonthDay(date) {
  return dayjs(date).format("MM月DD日");
}
export function getDiffDate(startDate, endDate) {
  return dayjs(endDate).diff(startDate, "day");
}
使用
import { formatMonthDay,getDiffDate } from "@/utils/format_date";
import { ref } from "vue";
const nowDate = new Date();
const newDate = new Date().setDate(nowDate.getDate() + 1);
const startDate = ref(formatMonthDay(nowDate));
const endDate = ref(formatMonthDay(newDate));
const stayCount = ref(getDiffDate(nowDate, newDate));