<template>
<view>
<view class="uni-padding-wrap">
<view class="uni-title">日期:{{year}}年{{month}}月{{day}}日</view>
</view>
<picker-view v-if="visible" :indicator-style="indicatorStyle" :value="value" @change="bindChange" class="picker-view">
<picker-view-column>
<view class="item" v-for="(item,index) in years" :key="index">{{item}}年</view>
</picker-view-column>
<picker-view-column>
<view class="item" v-for="(item,index) in months" :key="index">{{item}}月</view>
</picker-view-column>
<picker-view-column>
<view class="item" v-for="(item,index) in days" :key="index">{{item}}日</view>
</picker-view-column>
</picker-view>
</view>
</template>
<script>
export default {
data: function () {
const date = new Date()
const years = []
const year = date.getFullYear()
const months = []
const month = date.getMonth() + 1
const days = []
const day = date.getDate()
for (let i = 1990; i <= date.getFullYear(); i++) {
years.push(i)
}
for (let i = 1; i <= 12; i++) {
months.push(i)
}
for (let i = 1; i <= 31; i++) {
days.push(i)
}
return {
title: 'picker-view',
years,
year,
months,
month,
days,
day,
value: [9999, month - 1, day - 1],
visible: true,
indicatorStyle: height: 50px;
}
},
methods: {
bindChange: function (e) {
const val = e.detail.value
this.year = this.years[val[0]]
this.month = this.months[val[1]]
this.day = this.days[val[2]]
}
}
}
</script>
<style>
.picker-view {
width: 750rpx;
height: 600rpx;
margin-top: 20rpx;
}
.item {
height: 50px;
align-items: center;
justify-content: center;
text-align: center;
}
</style>

- 发布:2022-01-19 13:48
- 更新:2022-01-19 13:48
- 阅读:278
产品分类: uniapp/小程序/微信
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: 21H1
HBuilderX类型: 正式
HBuilderX版本号: 3.3.8
第三方开发者工具版本号: 1.05
基础库版本号: 2.21.1
项目创建方式: HBuilderX
操作步骤:
预期结果:
滑动到最上面的时候,会有一个回复的动画,如果在原生中设置:immediate-change=“true”,会在动画结束前设置值。我想要的是这种效果,但是在uni-app却实现不了
滑动到最上面的时候,会有一个回复的动画,如果在原生中设置:immediate-change=“true”,会在动画结束前设置值。我想要的是这种效果,但是在uni-app却实现不了
实际结果:
在uni-app中不能再动画结束前设置值
在uni-app中不能再动画结束前设置值
bug描述:
这里附加的是当前微信原生的picker-view和uniapp的picker-view的文档,其中有部分参数,比如:immediate-change这个参数就没有,导致和原生的体验不一样。

