我想做一个list组件,试过很多方法,一直不太满意。例如用js同步scrollLeft位置,但是精度不够,有时候会无法同步位置。
而用position:sticky; 效果会比较好,但是在IOS中,会出现问题。如下面图片所示。
<template>
<view style="white-space: nowrap; border: 0; display: flex;flex-shrink: 0; overflow-x: scroll;line-height: 120rpx;text-align: center;"
:style="[{height:stockListHeight + 'px'}]">
<view style="width: 250rpx; position:sticky;left: 0;z-index: 999;">
<view style="float: left;">
<view style="width: 250rpx; height: 120rpx; background-color:#F76260;position:sticky;top: 0;">商品名称</view>
<view v-for="c in 19" style="width: 250rpx; height: 120rpx; background-color:#F76260;">名称</view>
</view>
</view>
<veiw style="width: 500rpx;">
<view style="float: left;">
<view style="height: 120rpx; background-color: #0A98D5;white-space: nowrap; position: sticky; top: 0;">
<view v-for="c in 5" style="width: 250rpx; height: 120rpx; display: inline-block;">列头</view>
</view>
<view v-for="c in 19" style="height: 120rpx; background-color: #0A98D5;white-space: nowrap;">
<view v-for="c in 5" style="width: 250rpx; height: 120rpx; display: inline-block;">数据内容</view>
</view>
</view>
</veiw>
</view>
</template>
<script>
export default {
data() {
return {
stockListHeight: 0,
}
},
methods: {
},
onReady() {
var _self = this;
uni.getSystemInfo({
success: (e) => { // resu 可以获取当前屏幕的高度
_self.stockListHeight = e.windowHeight
}
})
}
}
</script>
<style>
</style>
2***@qq.com (作者)
我试过在appplus加上 "bounce": "none" 但是依旧好像也会这样子?请问您是如何解决的?感谢回复
2020-09-14 15:34
wenju
回复 2***@qq.com: 额 你这个是h5.. 肯定不生效
2020-09-14 16:55