uView2.0
uView2.0 copied to clipboard
IndexList 索引列表 计算ScrollView高度时候不符合预期
版本
2.0.31
转载链接
重现步骤
设置uni?.$u?.config?.unit = rpx
uni.$u.setConfig({
config: {
unit: 'rpx'
}
})
引入IndexList 索引列表,给定数据,
<u-index-list activeColor = "#56A7FF" :customNavHeight = "50">
<template v-for="(item, index) in itemArr" >
<!-- #ifdef APP-NVUE -->
<u-index-anchor :text="indexList[index]" :key="index"></u-index-anchor>
<!-- #endif -->
<u-index-item :key="index">
<!-- #ifndef APP-NVUE -->
<u-index-anchor :text="indexList[index]" color ='#56A7FF'></u-index-anchor>
<!-- #endif -->
<view class="list-cell" @click= "checkItem(item1)" v-for="(item1, index1) in item" :key="index1">
{{item1.mccName || ''}}
</view>
</u-index-item>
</template>
</u-index-list>
期望的结果是什么?
页面数据展示全屏
实际的结果是什么?
页面数据只展示了半屏
通过定位,发现计算scrollView高度的时候使用页面可视高度减去自定义状态栏的高度,然后通过内部计算方法addUnit计算得到,由于页面的可视距离高度得到的是px单位的高度,所以这里如果设置了uni?.$u?.config?.unit 为rpx,计算得到的结果就会有偏差,造成高度与预期结果不一致
经测试可以强制覆盖scroll-view的max-height ::v-deep .u-index-list { height: 100%; scroll-view { max-height: 100% !important; } }
如遇传入customNavHeight字段,再组件中处理逻辑是用
this.sys.windowHeight - this.customNavHeight
来进行处理的,如果是在外部用css样式覆盖,高度就会计算不准确。
目前处理方式是在页面中自己处理高度的计算方式然后通过css变量方式在style样式表中进行覆盖。
所以,这么久了,这个bug还是没有修复吗