小程序——scroll-view 页面不滚动与隐藏导航条

1、隐藏导航条,只要在该页面的 wxss 页中加入以下代码就可以

::-webkit-scrollbar {
  width: 0;
  height: 0;
  color: transparent;
}
2、页面不滚动的解决办法
    1、原因:我所碰到的 2 次页面不滚动都是因为 scroll-view 的宽度不对。
        scroll-view 的宽度应该是你设置的滚动区域的宽度,而实际上很容易就变成内部内容所撑开的全部宽度,在此,给 scroll-view 的父级 view 设置成你需要的可视区域的宽度,scroll-view 宽度设置 100%,这样问题就解决了。
    2、示例代码:
<!-- wxml -->
<view style="width:280px">
  <scroll-view class="scroll-view_H" scroll-x="true" style="width: 100%"  bindscrolltoupper="upper" bindscrolltolower="lower" bindscroll="scroll"  scroll-left="{{scrollLeft}}">
    <view id="green" class="scroll-view-item_H bc_green"></view>
    <view id="red"  class="scroll-view-item_H bc_red"></view>
    <view id="yellow" class="scroll-view-item_H bc_yellow"></view>
    <view id="blue" class="scroll-view-item_H bc_blue"></view>
  </scroll-view>
</view>
/* wxss */
.scroll-view_H{
  white-space: nowrap;
}
.scroll-view-item_H{
  display: inline-block;
  width: 200px;
  height: 100px;
}
.bc_green{
  background-color: green;
}
.bc_red{
  background-color: red;
}
.bc_yellow{
  background-color: yellow;
}
.bc_blue{
  background-color: blue;
}

结果:


猜你喜欢

转载自blog.csdn.net/BetterGG/article/details/80983154