<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}`
}
}
日期选择器picker(uni-app)
最新推荐文章于 2024-04-01 20:01:21 发布