<picker mode="date" :value="date" :start="startDate" :end="endDate" @change="bindDateChange">
<span class="uni-input">{{date}}</span>
<span class="iconfont icon-xiala-fill"></span>
</picker>
<script>
export default {
data() {
const currentDate = this.getDate({
format: true
})
return {
date: currentDate,
}
},
computed: {
startDate() {
return this.getDate('start');
},
endDate() {
return this.getDate('end');
}
}
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 if (type === 'end') {
year = year + 2;
}
month = month > 9 ? month : '0' + month;;
day = day > 9 ? day : '0' + day;
return `${year}-${month}-${day}`;
}
}
}
</script>

- 发布:2020-09-24 15:26
- 更新:2020-12-21 16:41
- 阅读:1642
产品分类: uniapp/小程序/微信
PC开发环境操作系统: Mac
PC开发环境操作系统版本号: macOS Catalina
HBuilderX类型: 正式
HBuilderX版本号: 2.7.14
第三方开发者工具版本号: 1.03.2009140
基础库版本号: 2.13.0
项目创建方式: HBuilderX
操作步骤:
预期结果:
正常显示日期选择器
正常显示日期选择器
实际结果:
日期选择器显示不完整
日期选择器显示不完整
2***@qq.com (作者)
谢谢
2020-10-07 18:31