使用mint ui 日期插件使用

1 下载之后,引入 mint ui

import Vue from ‘vue’
import { DatetimePicker } from ‘mint-ui’;
Vue.component(DatetimePicker.name, DatetimePicker)

2 template 中 使用组件
<mt-datetime-picker
v-model=“dateValue”
type=“date” // 类型 可以为 datetime’, ‘date’, ‘time’(根据需求来)
ref=“datePicker”
@visible-change=“handleVisibleChange” // 打印之后,显示true/false,是关闭模态框的
year-format="{value} 年"
month-format="{value} 月"
date-format="{value} 日"
:endDate=“new Date()”
@confirm=“handleConfirm”

</mt-datetime-picker>

3 需要 在你当前使用日期的地方,注册一个点击事件,触发日期控件
selectYear(){
this.$refs.datePicker.open(); // 调用官网方法
},

4 在 @confirm=“handleConfirm” 里处理

andleConfirm (value) {
this.year = value.getFullYear(); // 年月日都需要在 data中定义
this.month = value.getMonth() + 1;
this.date = value.getDate();
this.getAllStart = this.year +"/"+this.month+ “/”+this.date //用到双向绑定,字符串拼接
},

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值