当前位置:   article > 正文

VUE+Element-ui实战之el-calendar日历自定义显示内容

el-calendar

目录

1、确保添加el-calendar组件

2、遍历日期,确定显示内容

3、最终实现效果

4、完整代码


1、确保添加el-calendar组件

确保你的element引入了el-calendar组件,这里不再赘述

2、遍历日期,确定显示内容

3、最终实现效果

4、完整代码

  1. <template>
  2. <div class="main_con">
  3. <div style="text-align: left;">
  4. <H2>施工日志</H2>
  5. <el-divider></el-divider>
  6. </div>
  7. <el-calendar>
  8. <template slot="dateCell" slot-scope="{date, data}">
  9. {{ data.day.split('-').slice(1).join('-') }}
  10. <div style="width:100%;" v-for="item in scheduleData" :key="item">
  11. <el-tag type="danger" v-if="(item.workingDay).indexOf(data.day.split('-').slice(2).join('-'))!=-1">
  12. {{item.content}}
  13. </el-tag>
  14. </div>
  15. </template>
  16. </el-calendar>
  17. </div>
  18. </template>
  19. <script>
  20. export default {
  21. name: "PatrolSchedule",
  22. components: {},
  23. data() {
  24. return {
  25. value: new Date(),
  26. scheduleData: [
  27. {
  28. workingDay: "02",
  29. content: "土方开挖",
  30. },
  31. {
  32. workingDay: "03",
  33. content: "地基验坑",
  34. },
  35. {
  36. workingDay: "04",
  37. content: "地基回填",
  38. },
  39. {
  40. workingDay: "05",
  41. content: "基础垫层模",
  42. },
  43. {
  44. workingDay: "06",
  45. content: "基础垫层混凝土浇筑",
  46. },
  47. {
  48. workingDay: "07",
  49. content: "基础钢筋绑扎",
  50. },
  51. ],
  52. };
  53. },
  54. mounted() {},
  55. methods: {},
  56. };
  57. </script>
  58. <style scoped>
  59. /deep/.el-calendar-day {
  60. box-sizing: border-box;
  61. padding: 5px;
  62. height: 80px;
  63. }
  64. </style>

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/羊村懒王/article/detail/119009?site
推荐阅读
相关标签
  

闽ICP备14008679号