風水大師
風水大師
  • 发布:2019-01-27 19:31
  • 更新:2019-01-27 19:31
  • 阅读:1464

【报Bug】picker date模式,加了startdate和enddate后,选择有问题

分类:uni-app

[内容]
picker date模式,加了startdate和enddate,startdate为2019-01-27,enddate为2019-04-27,选择1月31号时,直接跳到4月27,选择不上1月31,选择2月1号时,有跳到了1月27,选择不上2月1日,用官方代码试验的。
重现步骤
[步骤]

<template>
<view>
<page-head :title="title"></page-head>
<view class="uni-title uni-common-pl">地区选择器</view>
<view class="uni-list">
<view class="uni-list-cell">
<view class="uni-list-cell-left">
当前选择
</view>
<view class="uni-list-cell-db">
<picker @change="bindPickerChange" :value="index" :range="array">
<view class="uni-input">{{array[index]}}</view>
</picker>
</view>
</view>
</view>

复制代码    <view class="uni-title uni-common-pl">时间选择器</view>  
    <view class="uni-list">  
        <view class="uni-list-cell">  
            <view class="uni-list-cell-left">  
                当前选择  
            </view>  
            <view class="uni-list-cell-db">  
                <picker mode="time" :value="time" start="09:01" end="21:01" @change="bindTimeChange">  
                    <view class="uni-input">{{time}}</view>  
                </picker>  
            </view>  
        </view>  
    </view>  

    <view class="uni-title uni-common-pl">日期选择器</view>  
    <view class="uni-list">  
        <view class="uni-list-cell">  
            <view class="uni-list-cell-left">  
                当前选择  
            </view>  
            <view class="uni-list-cell-db">  
                <picker mode="date" :value="date" :start="startDate" :end="endDate" @change="bindDateChange">  
                    <view class="uni-input">{{date}}</view>  
                </picker>  
            </view>  
        </view>  
    </view>  
</view>  

</template>
<script>
import {DateUtils} from './app.js'
export default {
data() {
const currentDate = this.getDate({
format: true
});
return {
title: 'picker',
array: ['中国', '美国', '巴西', '日本'],
index: 0,
date: currentDate,
time: '12:01'
}
},
computed: {
// startDate() {
// let a = DateUtils.toLong(DateUtils.addDays('2019-01-27', 1));
// console.log(a);
// return a;
// },
// endDate() {
// let b = DateUtils.toLong(DateUtils.addDays('2019-01-27',7));
// console.log(b);
// return b;
// }
startDate() {
// let a = DateUtils.toLong(DateUtils.addDays('2019-01-27', 1));
// console.log(a);
let a = this.getDate('start');
console.log(a);
return a;
},
endDate() {
// let b = DateUtils.toLong(DateUtils.addDays('2019-01-27',90));
let b = this.getDate('end');
console.log(b);
return b;
}
},
methods: {
bindPickerChange: function(e) {
console.log('picker发送选择改变,携带值为', e.target.value)
this.index = e.target.value
},
bindDateChange: function(e) {
this.date = e.target.value
},
bindTimeChange: function(e) {
this.time = 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;  
                day = day;  
            } else if (type === 'end') {  
                // year = year + 2;  
                month = month + 3;  
            }  
            month = month > 9 ? month : '0' + month;;  
            day = day > 9 ? day : '0' + day;  

            return `${year}-${month}-${day}`;  
        }  
    }  
}  

</script>

<style>

</style>
[结果]
[期望]
[如果语言难以表述清晰,可以拍一个视频或截图,有图有真相]

IDE运行环境说明
HBuilderX]
[IDE版本号]
HBuilderX 1.3.2 20181214
[windows版本号]
window 7
联系方式
[QQ] 1149603879

2019-01-27 19:31 负责人:无 分享
已邀请:

该问题目前已经被锁定, 无法添加新回复

  • 标题 / 粗斜体
  • 代码片段
  • 超链接 / 图片 / 视频
  • 列表 / 引用

文章内容较多时,可以用标题分段 :

## 大标题 
### 小标题

斜体 / 粗体 :

**粗体** 
*斜体*
***粗斜体***

代码片段 :

``` javascript
代码片段
```

超链接 :

[链接文字](链接地址) 例: [百度](http://www.baidu.com)

图片 :

![图片说明](图片地址) 例: ![百度logo](http://www.baidu.com/img/bdlogo.gif)

视频 :

!![视频说明](视频地址) 例: !![优酷视频](http://youku.com)

有序列表 :

1. 123
2. 123
3. 123

无序列表 :

- 123
- 123
- 123

引用 : ( 双回车后结束引用 )

> 引用内容
引用内容
引用内容