mpvue 微信小程式 picker 日期元件,使用方法
阿新 • • 發佈:2019-01-24
上圖不說話
template 部分
<div class="index_section">
<picker mode="date"
:value="startDate"
:start="pickerStart" end="2217-09-01" @change="bindDateChangeStart($event)">
<div class="index_picker">
<div class="">起始日期</div>
<div class="">{{ startDate }}</div >
</div>
</picker>
</div>
script部分
data () {
return {
startDate:'2018-05-9',
endDate:'2018-02-21',
pickerStart:'2018-05-6',
}
},
mounted(){
// 設定時間
let today = this.getToday()
this.startDate = today
this.endDate = today
this.pickerStart = today
},
methods: {
getToday(){
let myDate = new Date();
let myMonth = myDate.getMonth() + 1;
if(myMonth < 10){
myMonth = '0'+ myMonth; //補齊
}
let mydate = myDate.getDate();
if(myDate.getDate()<10){
mydate = '0'+ myDate.getDate(); //補齊
}
let today = myDate.getFullYear() + '-' + myMonth + '-' + mydate;
return today
},
}
好像說完了……