<picker mode="date" :value="date" :start="startDate" :end="endDate" @change="getDateChange">
<view class="timerText">{{date}}</view>
</picker>
data() {
return {
date: ""
}
},
computed: {
startDate () {
return this.getDate("start")
},
endDate () {
return this.getDate("end")
}
},
mounted () {
this.date = this.getDate({
format: true
})
}
methods: {
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 {
year = year + 2
}
month = month > 9 ? month : "0" + month
day = day > 9 ? day : '0' + day
return `${year}-${month}-${day}`
}
}
版权声明:本文为qq_38779317原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。