核心代码
<a-config-provider :locale="locale">
<a-calendar v-model:value="value" >
<template #dateCellRender="{ current }">
<div class="notes-month">
{{ current.date() }}
<section>+111</section>
+10%
</div>
</template>
<template #monthCellRender="{ current }">
<div v-if="getMonthData(current)" class="notes-month">
<section>+111</section>
+10%
</div>
</template>
</a-calendar>
</a-config-provider>
//ant-design-vue 中文包
import zhCN from "ant-design-vue/es/locale/zh_CN";
import dayjs from "dayjs"
import "dayjs/locale/zh-cn"
dayjs.locale("zh-cn")
网上部分文章说是用的moment,但是我用的是dayjs呀
全部代码
<template>
<!-- 整体的配置 比如中英文配置 start-->
<a-row>
<a-col :span="24" style="padding: 20px;">
<a-config-provider :locale="locale">
<a-calendar v-model:value="value" :locale="locale">
<template #dateCellRender="{ current }">
<div class="notes-month">
{{ current.date() }}
<section>+111</section>
+10%
</div>
</template>
<template #monthCellRender="{ current }">
<div v-if="getMonthData(current)" class="notes-month">
<section>+111</section>
+10%
</div>
</template>
</a-calendar>
</a-config-provider>
</a-col>
</a-row>
<!-- 整体的配置 比如中英文配置 end-->
</template>
<script setup>
import {
ref,
computed,
inject,
onMounted,
unref,
onBeforeUpdate,
reactive,
watch
} from "vue";
//pinia
import { useStore } from "@/stores/index.ts";
//vue-router
import { useRouter, useRoute } from "vue-router";
//ant-design-vue message提示组件
import { message } from "ant-design-vue";
//ant-design-vue 中文包
import zhCN from "ant-design-vue/es/locale/zh_CN";
import dayjs from "dayjs"
import "dayjs/locale/zh-cn"
dayjs.locale("zh-cn")
//0.1 分页器中文配置
let locale = ref(zhCN);
//0.2 pinia配置
const store = useStore();
//0.3 vue-axios配置
const axios = inject("axios"); // inject axios
//0.4 vue-router配置
const router = useRouter(); // 必须在setup的根作用域调用,在函数中调返回undefined
const route = useRoute(); // 必须在setup的根作用域调用,在函数中调返回undefined
const value = ref();
const getListData = value => {
let listData;
switch (value.date()) {
case 8:
listData = [
{
type: 'warning',
content: '1',
},
];
break;
case 10:
listData = [
{
type: 'warning',
content: 'This is warning event.',
},
{
type: 'success',
content: 'This is usual event.',
},
{
type: 'error',
content: 'This is error event.',
},
];
break;
default:
}
return listData || [];
};
const getMonthData = value => {
if (value.month() === 8) {
return 1394;
}
};
//初始化
onMounted(() => {
console.log("当前语言包:", locale.value);
});
</script>
<style>
.home {
font-size: 12px;
}
.redfont {
color: red;
}
.greenfont {
color: green;
}
.blackfont {
color: black;
}
.smallfont {
font-size: 5px;
}
</style>