1、确保添加el-calendar组件
确保你的element引入了el-calendar组件
这里不再赘述
2、遍历日期,确定显示内容

3、最终实现效果

4、完整代码
<template>
<div class="main_con">
<div style="text-align: left;">
<h2>施工日志</h2>
<el-divider></el-divider>
</div>
<el-calendar>
<template slot="datecell" slot-scope="{date, data}">
{{ data.day.split('-').slice(1).join('-') }}
<div style="width:100%;" v-for="item in scheduledata" :key="item">
<el-tag type="danger" v-if="(item.workingday).indexof(data.day.split('-').slice(2).join('-'))!=-1">
{{item.content}}
</el-tag>
</div>
</template>
</el-calendar>
</div>
</template><script>
export default {
name: "patrolschedule",
components: {},
data() {
return {
value: new date(),
scheduledata: [
{
workingday: "02",
content: "土方开挖",
},
{
workingday: "03",
content: "地基验坑",
},
{
workingday: "04",
content: "地基回填",
},
{
workingday: "05",
content: "基础垫层模",
},
{
workingday: "06",
content: "基础垫层混凝土浇筑",
},
{
workingday: "07",
content: "基础钢筋绑扎",
},
],
};
},
mounted() {},
methods: {},
};
</script><style scoped>
/deep/.el-calendar-day {
box-sizing: border-box;
padding: 5px;
height: 80px;
}
</style>总结
以上为个人经验,希望能给大家一个参考,也希望大家多多支持代码网。
发表评论