您好,欢迎来到税程财经网。
搜索
您的当前位置:首页使用mint-ui时间插件时怎么获取选择值

使用mint-ui时间插件时怎么获取选择值

来源:税程财经网


这次给大家带来使用mint-ui时间插件时怎么获取选择值,使用mint-ui时间插件获取选择值的注意事项有哪些,下面就是实战案例,一起来看一下。

<p > {{pickerValue}}</p>
<mt-datetime-picker
 ref="picker" 每一个都要填上这一条open
 type="time"
 @confirm="handleConfirm" 设置点击确定
 v-model="pickerValue">
</mt-datetime-picker>
data () {
 return {
 pickerValue:null, 定义
methods:{
openPicker() {
 this.$refs.picker.open();设置开始
 },
handleConfirm(){ console.log(this.pickerValue) ;获取值},
转换小时
formatDate(date) {
 const y = date.getFullYear()
 let m = date.getMonth() + 1
 m = m < 10 ? '0' + m : m
 let d = date.getDate()
 d = d < 10 ? ('0' + d) : d
 return y + ' ' + m + ' ' + d
},
handleConfirm(){
 let a = this.pickerValue
 // console.log(a.split(" ")) ;
 this.zheng=this.formatDate(this.$refs.picker.value)
 console.log(this.formatDate(this.$refs.picker.value))
 // console.log(this.value) ;
},
设置当前日期为初始日期
<mt-datetime-picker :startDate="startDate"</mt-datetime-picker>
data(){
 return{
 startDate: new Date(),
 }
}
设置默认值
this.zheng=new Date().getFullYear()+'年'+new Date().getMonth()+1+'月'+new Date().getDate()+'日

相信看了本文案例你已经掌握了方法,更多精彩请关注Gxl网其它相关文章!

推荐阅读:

使用adb shell+node.js实现抖音自动抢红包

怎样实现百度指数爬虫功能

Copyright © 2019- shuicheng.net 版权所有

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务