Home > Web Front-end > JS Tutorial > How to get the selection value when using the mint-ui time plug-in

How to get the selection value when using the mint-ui time plug-in

php中世界最好的语言
Release: 2018-04-12 17:17:23
Original
1960 people have browsed it

This time I will show you how to obtain the selection value when using the mint-ui time plug-in. What are the precautions for using the mint-ui time plug-in to obtain the selection value. The following is a practical case. Let’s take a look.

<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()+'日
Copy after login

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!

Recommended reading:

Use adb shell node.js to realize Douyin automatically grab red envelopes

How to implement Baidu index crawler function

The above is the detailed content of How to get the selection value when using the mint-ui time plug-in. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template