uni-app顶部导航栏 下拉滑动固定到屏幕顶部

╰半夏微凉° 2022-12-23 09:53 337阅读 0赞

示例图片
在这里插入图片描述

代码

  1. <template>
  2. <view style="display: flex;flex: row; position:fixed; left: 0; width: 100%; top: 30;z-index: 999;">
  3. <scroll-view scroll-x class="bg-white nav" scroll-with-animation :scroll-left="scrollLeft">
  4. <view class="cu-item" :class="index==TabCur?'text-green cur':''" v-for="(item,index) in statusList" :key="index" @tap="tabSelect" :data-id="index">
  5. { { item}}
  6. </view>
  7. </scroll-view>
  8. </view>
  9. </template>
  10. <script>
  11. export default {
  12. components: {
  13. },
  14. data() {
  15. return {
  16. TabCur: 0,
  17. scrollLeft: 0
  18. }
  19. },
  20. methods: {
  21. tabSelect(e) {
  22. this.TabCur = e.currentTarget.dataset.id;
  23. this.scrollLeft = (e.currentTarget.dataset.id - 1) * 60
  24. console.log(this.TarCur)
  25. },
  26. }
  27. }
  28. </script>
  29. <style>
  30. /* ================== 导航栏 ==================== */
  31. .nav {
  32. white-space: nowrap;
  33. }
  34. ::-webkit-scrollbar {
  35. display: none;
  36. }
  37. .nav .cu-item {
  38. height: 90upx;
  39. display: inline-block;
  40. line-height: 90upx;
  41. margin: 0 10upx;
  42. padding: 0 20upx;
  43. }
  44. .nav .cu-item.cur {
  45. border-bottom: 4upx solid;
  46. }
  47. .text-green,
  48. .line-green,
  49. .lines-green {
  50. color: #39b54a;
  51. }
  52. .bg-white {
  53. background-color: #ffffff;
  54. color: #666666;
  55. }
  56. .nav .cu-item.cur {
  57. border-bottom: 4upx solid;
  58. }
  59. </style>

发表评论

表情:
评论列表 (有 0 条评论,337人围观)

还没有评论,来说两句吧...

相关阅读