使用本机滚动时使滚动条在离子内容中可见

2023-11-26

我在用overflow-scroll = "true"让 ionic 使用原生滚动:

 <ion-content overflow-scroll = "true">
   <ion-list>
     <ion-item ng-repeat="foo in bar">
       {{foo.label}}
     </ion-item>
   </ion-list>
 </ion-content>

这真的很棒(表演真的很好)。唯一的问题是(垂直)滚动条消失了。

根据文档,我尝试添加scrollbar-y="true" to ion-content,但这没有用。

我还尝试将其添加到我的 css 中:

::-webkit-scrollbar {
    -webkit-appearance: none;
}

::-webkit-scrollbar:vertical {
    width: 11px;
}

::-webkit-scrollbar:horizontal {
    height: 11px;
}

::-webkit-scrollbar-thumb {
    border-radius: 8px;
    border: 2px solid white;
    background-color: rgba(0, 0, 0, .5);
}

::-webkit-scrollbar-track {
    background-color: #fff;
    border-radius: 8px;
}

...但这也不起作用。

本文(查找“本机滚动”)表示该问题可以使用 css 解决。

有人知道该怎么做吗?


The @Gerhard Carbó 建议的答案迄今为止我找到的最接近解决方案...它确实有效,但是:

  • 滚动条不会自动隐藏
  • 动画非常生涩

所以我相信我现在会坚持不使用滚动条。

另请注意,这在 Android 上的 Google Chrome 上运行良好,所以希望有一天它能得到修复。但为什么 webview 落后 chrome 这么多,我无法理解......

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

使用本机滚动时使滚动条在离子内容中可见 的相关文章

随机推荐