wike-scrollview.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <template>
  2. <view class="flex">
  3. <scroll-view scroll-y="true" style="width: 30%;"
  4. :style="{height:scrollHeight + 'px','background-color':leftBgColor,'font-size':leftFs+'rpx'}">
  5. <view v-for="(item,index) in viewList" class="text-overflow flex py-30 pr-20 align-center"
  6. @click="leftClick(index,item)" :class="activeIndex==index?'selected':''">
  7. <view style="width: 8rpx;height: 50rpx;"
  8. :style="{'background-color':activeIndex==index?leftSelected:''}"></view>
  9. <view class="pl-20" :style="{color:activeIndex==index?leftSelectedColor:'',width: 115+'px'}">
  10. {{item.title}}
  11. </view>
  12. </view>
  13. </scroll-view>
  14. <scroll-view scroll-y="true" style="width: 70%;"
  15. :style="{ height:scrollHeight + 'px','background-color':rightBgColor,'font-size':rightFs+'rpx'}">
  16. <view class="wike_ad">
  17. <wike-ad></wike-ad>
  18. </view>
  19. <navigator v-for="(item, index) in viewList[activeIndex].children" :key="index" class="helpme" :url="'/pages/template/detail?id=' + item.id">
  20. <view class="title">{{ item.title }}</view>
  21. <view class="sub_title">{{ item.sub_title }}</view>
  22. </navigator>
  23. <view style="height: 30rpx;">
  24. </view>
  25. </scroll-view>
  26. </view>
  27. </template>
  28. <script>
  29. export default {
  30. name: "gjs-scrollView",
  31. props: {
  32. //左右列表
  33. viewList: {
  34. type: Array,
  35. default: []
  36. },
  37. //scroll-view的高度
  38. scrollHeight: {
  39. type: Number,
  40. default: 826
  41. },
  42. //左边区域的背景色
  43. leftBgColor: {
  44. type: String,
  45. default: '#F6F6F6'
  46. },
  47. //右边区域的背景色
  48. rightBgColor: {
  49. type: String,
  50. default: '#FFFFFF'
  51. },
  52. //左边区域的字体大小(最好不改)
  53. leftFs: {
  54. type: Number,
  55. default: 34
  56. },
  57. // //右边区域的字体大小(最好不改)
  58. rightFs: {
  59. type: Number,
  60. default: 32
  61. },
  62. //左边选中的颜色
  63. leftSelected: {
  64. type: String,
  65. default: '#26b3a0'
  66. },
  67. leftSelectedColor: {
  68. type: String,
  69. default: '#26b3a0'
  70. }
  71. },
  72. data() {
  73. return {
  74. activeIndex: 0,
  75. position: 'sv-0',
  76. // leftFs: 32,
  77. // rightFs: 32,
  78. };
  79. },
  80. methods: {
  81. leftClick(e, item) {
  82. this.activeIndex = e
  83. this.$emit('leftClick', item.title)
  84. },
  85. rightClick(e) {
  86. this.$emit('rightClick', e)
  87. },
  88. }
  89. }
  90. </script>
  91. <style lang="scss">
  92. .flex {
  93. display: flex;
  94. flex-direction: row;
  95. }
  96. .py-30 {
  97. padding-top: 30rpx;
  98. padding-bottom: 30rpx;
  99. }
  100. .pr-20 {
  101. padding-right: 20rpx;
  102. }
  103. .pl-20 {
  104. padding-left: 20rpx;
  105. }
  106. .selected {
  107. background-color: #FFFFFF;
  108. }
  109. /* 超出部分显示... */
  110. .text-overflow {
  111. overflow: hidden;
  112. /*超出部分隐藏*/
  113. white-space: nowrap;
  114. /*不换行*/
  115. text-overflow: ellipsis;
  116. /*超出部分文字以...显示*/
  117. }
  118. .align-center {
  119. align-items: center;
  120. }
  121. .helpme {
  122. background: #f5f8f7;
  123. border-radius: 20rpx;
  124. padding: 30rpx;
  125. margin: 30rpx;
  126. /* width: 48%;
  127. margin-bottom: 30rpx; */
  128. /* height: 92px; */
  129. .title {
  130. font-size: 32rpx;
  131. font-weight: bold;
  132. margin-bottom: 18rpx;
  133. color: #000;
  134. overflow:hidden; text-overflow:ellipsis; white-space:nowrap
  135. }
  136. .sub_title {
  137. color: #8f9ca2;
  138. font-size: 24rpx;
  139. overflow: hidden;
  140. text-overflow: ellipsis;
  141. display: -webkit-box;
  142. -webkit-box-orient: vertical;
  143. -webkit-line-clamp: 2;
  144. }
  145. }
  146. .wike_ad{
  147. margin: 30rpx;
  148. }
  149. //去掉横向滚动条
  150. /* 滚动条宽度 */
  151. #noneScrollbar .el-scrollbar__thumb {
  152. display: none;
  153. }
  154. #noneScrollbar .el-scrollbar__wrap {
  155. overflow-x: hidden;
  156. overflow-y: auto;
  157. }
  158. </style>