The date picker was written like this before:
<picker mode="date" :value="date" start="" end="" @change="bindDateChange">
<view class="picker">
<text class="tishi2">{
{date}}</text>
</view>
</picker>
The date cannot be selected when Android is packaged and installed on the mobile phone. The reason is that the attribute values of start and end are not set. Setting these two values can be selected:
<template>
<view class="container">
<picker mode="date" :value="date" :start="startDate" :end="endDate" @change="bindDateChange">
<text>{
{date}}</text>
</picker>
</view>
</template>
<script>
function getDate(type) {
const date = new Date();
let year = date.getFullYear();
let month = date.getMonth() + 1;
let day = date.getDate();
if (type === 'start') {
year = year - 100;
} else if (type === 'end') {
year = year + 100;
}
month = month > 9 ? month : '0' + month;;
day = day > 9 ? day : '0' + day;
return `${year}-${month}-${day}`;
}
export default {
data() {
return {
date: getDate({
format: true
}),
startDate:getDate('start'),
endDate:getDate('end'),
}
},
methods: {
//日期选择
bindDateChange: function(e) {
this.date = e.detail.value
}
},
onLoad() {
}
}
</script>
<style>
</style>