前端 vue v-calendar 日历组件

本文介绍了如何在 Vue 项目中使用 v-calendar 组件。首先通过 npm 安装 v-calendar,然后在 main.js 文件中引入并注册。接着展示了在组件中如何监听和获取日历的年月信息,包括在 mounted 生命周期钩子中获取初始年月以及在改变月份时更新年月的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

vue v-calendar 的日历组件的使用

1.安装
npm install v-calendar;
import VCalendar from ‘v-calendar’;
在main.js:
import VCalendar from ‘v-calendar’; // 引入日历插件
Vue.use(VCalendar, {
componentPrefix: ‘vc’
2.使用

<v-calendar :attributes='attributes' @dayclick="onDayClick"  v-on:choseDay="clickDay"  ref="calendars" is-expanded @transition-start="dateTime" ></v-calendar>
  data() {
            return {
                calendar: '请选择日历',
                calendar_list: [],
                selectedDate: [],
                days: [],  //所选择的日期
                calendars:'',
                }


点击的时候获取年月份

 //改变时
            onDayClick(day) {
                
               

            },


如果想进来的时候获取年月份在mounted里面执行ref

  mounted: function () {
            this.calendars=this.$refs.calendars;
            this.moth =this.calendars.firstPage.month;
            this.year = this.calendars.firstPage.year;
            }

改变月份时获取年和月;

  methods: {
   dateTime(value){
                this.calendars=this.$refs.calendars;
                this.moth =this.calendars.firstPage.month;
                this.year = this.calendars.firstPage.year;
                }
  }
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值