<view>
<picker mode="date" :value="date" :start="startDate" :end="endDate" @change="bindDateChange">
<view class="">{{date}}</view>
</picker>
</view>
data() {
const currentDate = this.getDate({
format: true
})
return {
date: currentDate,
time: '12:01'
}
},
methods: {
bindDateChange: function(e) {
this.date = e.target.value
},
getDate(type) {
const date = new Date();
let year = date.getFullYear();
let month = date.getMonth() + 1;
let day = date.getDate();
if (type === 'start') {
year = year - 60;
} else if (type === 'end') {
year = year + 2;
}
month = month > 9 ? month : '0' + month;;
day = day > 9 ? day : '0' + day;
return `${year}-${month}-${day}`;
}
},
可直接显示文本插值的内容
网友评论