日历组件 日期筛选

50 篇文章 0 订阅
2 篇文章 0 订阅

效果图:

组件部分

<template>
  <div class="div_dateBlueSky">
    <div class="arrow_dateBlueSky" @click="left"></div>
    <div class="font_dateBlueSky">{{this.date.format('YYYY年M月')}}</div>
    <div class="arrow_dateBlueSky1" @click="right"></div>
  </div>
</template>

<script>
  import dayjs from 'dayjs'
  export default {
    name: "dateBlueSky",
    data(){
      return{
        date:'',
        i:0
      }
    },
    methods: {
      left() {
        // console.log("左");
        this.i=this.i-1;
        this.date=dayjs().add(this.i, 'months');
        this.$emit('saveDate',this.date);
      },
      right() {
        this.i=this.i+1;
        // console.log("右");
        this.date=dayjs().add(this.i, 'months');
        this.$emit('saveDate',this.date);
      }
    },
    created(){
      // console.log(dayjs().format('YYYY年MM月'));
      this.date=dayjs();
    }
  }
</script>

<style scoped>
  .div_dateBlueSky {
    display: flex;
    flex-direction: row;
    width: 136px;
    justify-content: center;
    align-content: center;
  }

  .font_dateBlueSky {
    width: 105px;
    margin-left: 8px;
    font-size: 16px;
    font-family: MicrosoftYaHei;
    color: #FFFFFF;
    padding: 0px 0px 0px 0px;
    text-align: center;
  }

  .arrow_dateBlueSky {
    margin-top: 1px;
    width: 14px;
    height: 16px;
    background-image: url("../img/leftDark.png");
    background-repeat: no-repeat;
    background-size: 100% 100%;
    padding: 1px 2px 1px 2px;
    cursor: pointer;
  }

  .arrow_dateBlueSky1 {
    margin-top: 1px;
    margin-left: 8px;
    width: 14px;
    height: 16px;
    background-image: url("../img/rightDark.png");
    background-repeat: no-repeat;
    background-size: 100% 100%;
    padding: 1px 2px 1px 2px;
    cursor: pointer;
  }
</style>

需要安装 dayjs 插件

引用方法:

Dayjs使用教程_npm install dayjs_小胖梅前端的博客-CSDN博客

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值