7***@qq.com
7***@qq.com
  • 发布:2020-12-23 17:33
  • 更新:2023-08-17 10:50
  • 阅读:1045

【问题已解决】picker-view 在nvue中使用条目出现错乱

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: winds10

HBuilderX类型: 正式

HBuilderX版本号: 2.9.8

手机系统: Android

手机系统版本号: Android 10

手机厂商: 小米

手机机型: mix2s

页面类型: nvue

打包方式: 云端

项目创建方式: HBuilderX

示例代码:

<template>
<view class="content">
<picker-view class="date_picker_view" :indicator-style="indicatorStyle" :value="values" @change="bindChange">
<picker-view-column class="date">

         <span :style="{lineHeight:lineHeight+'px',height:lineHeight+'px'}" v-for="(item, index) in years" :key="index" class="date_picker_view_item" style="font-size: 30rpx;height: 64px;" >{{ item }}年</span>      

            </picker-view-column >  
    </picker-view>  
</view>  

</template>

<script>
import gppDatePicker from '../../components/gpp-datePicker/gpp-datePicker.vue';
export default {
components: {
gppDatePicker
},
data() {
return {
indicatorStyle: height: ${Math.round(uni.getSystemInfoSync().screenWidth / (750 / 100))}px;, //pickerview样式
startDate: '1949-01-01',
endDate: '2122-09-20',
pickerDate: '2020-11-25',
years: [],
values: [],
lineHeight:Math.round(uni.getSystemInfoSync().screenWidth / (750 / 100))
};
},
onLoad() {
for (var i = 1949; i < 2000; i++) {
this.years.push(i);
}
console.info(this.lineHeight)
},
methods: {
onCancel(e) {
console.log(e);
},
onConfirm(e) {
this.pickerDate = e.dateValue;
},
bindChange() {}
}
};
</script>

<style>
.date_picker_view_item {
align-items: center;
justify-content: center;
text-align: center;
font-size: 30rpx;
color: #333333;

margin: 0!important;  
padding: 0!important;  

}
.span{
margin: 0;
padding: 0;
}
.date{
padding:0;
margin: 0;
}
.date_picker_view {
width: 150rpx;
height: 600rpx;

}  

.content {
display: flex;
align-items: center;
justify-content: center;

}
.text-area {
display: flex;
justify-content: center;
align-items: center;
}
.title {
font-size: 36rpx;
color: #8f8f94;
}
</style>

操作步骤:

直接运行滑动到最后年份不居中 vue是居中的nvue 就偏下

预期结果:

文字居中

实际结果:

文字偏下

bug描述:

使用picker-view在nvue界面做日期选择当数据过长时候,会出现错位

2020-12-23 17:33 负责人:无 分享
已邀请:
DCloud_UNI_Anne

DCloud_UNI_Anne

  • 7***@qq.com (作者)

    我就是用官方示例改的,只不过我用的是nvue

    2020-12-23 17:40

  • DCloud_UNI_Anne

    回复 7***@qq.com: 目前nvue页面,picker-view-column标签里面用text标签,需要自己写下高和文字居中。

    2020-12-23 18:11

  • 7***@qq.com (作者)

    回复 DCloud_UNI_Anne: 是用的text标签,文字居中用了行高=高度 text-align: center;

    2020-12-24 09:38

  • ddpapa

    回复 7***@qq.com: 大佬,解决了吗,我也遇到了问题,使用官方的例子,在nvue里面,第一列显示有点错乱,就是文字没有居中,有点偏下

    2021-10-15 11:44

l***@163.com

l***@163.com

是怎么解决的呀,我也出现的是这个问题

Ndie

Ndie

在text标签里加上高度和行高,且只能用px,这样就好了

要回复问题请先登录注册