基于vue的简单折叠面板的实现 uniapp自定义样式折叠面板

太过爱你忘了你带给我的痛 2021-08-31 04:22 1776阅读 0赞

好叭 今天写折叠面板功能~~~ 最近在写uniapp 设计图里面有一个折叠面板功能

但是查看了基于uniapp的组件 及u-view的折叠面板 都无法自定义其标题内容 所以只能自己写一个咯

用vue写还是很快的 起码我同事五分钟就给我写完了 在这里插入图片描述话不多说上代码

在这里插入图片描述

在这里插入图片描述

css部分

这里有个地方一定要注意 就是列表里面一定要有一个开关,用来控制开关的我这里叫open
假数据放在这里 叫做list 折叠面板的样式可以自己调呀 有什么不喜欢的就改动吧

  1. <template>
  2. <view class="Suborder">
  3. <view v-for="(item, index) in list" :key="index" class="collaose">
  4. <view @tap="handleclick(index)" class="section louis-space-between ">
  5. <view class="box">
  6. <view class="top louis-space-between ">
  7. <view style="color:#333333 ;">143352546478896523</view>
  8. <view style="color:#FB5F10;">¥1.26</view>
  9. </view>
  10. <view class="bottom louis-space-between ">
  11. <text style="color:#666666 ;">大鲨鱼-2020-07-20 15:23:02</text>
  12. <text>未结算</text>
  13. </view>
  14. </view>
  15. <view class="louis-inline-block incon"><u-icon name="arrow-down" size="28"></u-icon></view>
  16. </view>
  17. <view v-show="item.open" class="louis-15px">
  18. <view class="alllist louis-bgfff">
  19. <view class="list louis-bgfff">
  20. <view class="louis-flex louis-lpadding">
  21. <view class="imgbox louis-smpadding">
  22. <image
  23. style="width: 140rpx;height: 154rpx;"
  24. src="http://zons.oss-cn-shenzhen.aliyuncs.com/upload/20200717/20200717/0.69995000 1594955210e5218cde16760c7b6011097d27e9ccf2.jpg"
  25. mode=""
  26. ></image>
  27. </view>
  28. <view style="margin-left: 10rpx;" class="righttext">
  29. <view style="width: 500rpx;margin-top: 10rpx;" class="u-font-30 louis-space-between">
  30. <text style="color: #333333;">一片式休闲彩虹拖鞋</text>
  31. <text style="color: #FB5F10">¥1.26</text>
  32. </view>
  33. <view class="u-font-30" style="margin-top: 10rpx; color: #666666;">实付:¥96.80</view>
  34. <view class="number" style="color:#999999 ;">数量:1</view>
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. </view>
  41. </view>
  42. </template>
  43. <script>
  44. export default {
  45. data() {
  46. return {
  47. pagesize: 6,
  48. list: null,
  49. keyword: '',
  50. current: 0,
  51. list: [
  52. {
  53. head: '赏识在于角度的转换',
  54. body: '只要我们正确择取一个合适的参照物乃至稍降一格去看待他人,值得赏识的东西便会扑面而来',
  55. open: true
  56. },
  57. {
  58. head: '生活中不是缺少美,而是缺少发现美的眼睛',
  59. body: '学会欣赏,实际是一种积极生活的态度,是生活的调味品,会在欣赏中发现生活的美',
  60. open: false
  61. },
  62. {
  63. head: '周围一些不起眼的人、事、物,或许都隐藏着不同凡响的智慧',
  64. body: '但是据说雕刻大卫像所用的这块大理石,曾被多位雕刻家批评得一无是处,有些人认为这块大理石采凿得不好,有些人嫌它的纹路不够美',
  65. open: false
  66. }
  67. ]
  68. };
  69. },
  70. onPullDownRefresh() {
  71. uni.stopPullDownRefresh();
  72. },
  73. onReachBottom(e) {
  74. console.log('触底加载更多');
  75. },
  76. mounted() { },
  77. methods: {
  78. change(index) {
  79. this.current = index;
  80. },
  81. handleclick(index) {
  82. this.list[index].open = !this.list[index].open;
  83. if (this.list[index].open == true) {
  84. for (var i = 0; i < this.list.length; i++) {
  85. if (i == index) {
  86. this.list[i].open = true;
  87. } else {
  88. this.list[i].open = false;
  89. }
  90. }
  91. }
  92. }
  93. }
  94. };
  95. </script>
  96. <style scoped lang="less">
  97. .item {
  98. display: inline-block;
  99. border: 1px solid #c0c0c0;
  100. font-size: 27rpx;
  101. padding: 5rpx 10rpx;
  102. border-radius: 10rpx 0rpx 0rpx 10rpx;
  103. // border-right: 0px;
  104. &:nth-child(2) {
  105. border-left: 0px;
  106. border-radius: 0rpx 10rpx 10rpx 0rpx;
  107. }
  108. }
  109. #itemindxs {
  110. color: #ffffff;
  111. background-color: #000000;
  112. border: 1px solid #000000;
  113. }
  114. .serch {
  115. padding: 10rpx;
  116. background-color: #f2f2f2;
  117. }
  118. .topbabs {
  119. // margin-top: 15rpx;
  120. background-color: #f6f6f6;
  121. padding: 10rpx 0rpx;
  122. }
  123. .noaddress {
  124. margin-top: 300rpx;
  125. #img {
  126. width: 200rpx;
  127. height: 200rpx;
  128. margin-bottom: 50rpx;
  129. }
  130. .buttonblue {
  131. margin-top: 50rpx;
  132. background-color: #5292f3;
  133. padding: 20rpx 50rpx;
  134. color: #ffffff;
  135. display: inline-block;
  136. border-radius: 50rpx;
  137. }
  138. }
  139. .cscs {
  140. width: 350rpx;
  141. overflow: hidden;
  142. overflow-wrap: break-word;
  143. font-size: 30rpx;
  144. }
  145. .number {
  146. height: 37rpx;
  147. font-size: 26rpx;
  148. font-weight: 400;
  149. line-height: 37rpx;
  150. color: rgba(153, 153, 153, 1);
  151. margin-top: 10rpx;
  152. }
  153. </style>
  154. <style lang="less" scoped>
  155. page {
  156. background-color: #f6f6f6;
  157. }
  158. .section {
  159. // height:145rpx ;
  160. background-color: #fff;
  161. border-top: 1px solid rgba(226, 226, 226, 1);
  162. .box {
  163. padding: 30rpx;
  164. flex: 80%;
  165. }
  166. .incon {
  167. margin-top: 5%;
  168. margin-right: 20rpx;
  169. }
  170. .top {
  171. margin: 10rpx;
  172. margin-left: 0;
  173. }
  174. }
  175. .alllist {
  176. border-top: 1px solid rgba(226, 226, 226, 1);
  177. }
  178. .isColor {
  179. color: #fea91a;
  180. }
  181. .isGreen {
  182. color: #29ab91;
  183. }
  184. </style>

好了 今天其实是闲的没事干啦 然后就来随便写点东西啊 马上下班啦

约了小伙伴去玩 啦啦啦

在这里插入图片描述

发表评论

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

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

相关阅读

    相关 jQuery 折叠面板

    手风琴是非常常见而实用的效果,本篇文章示例一个简单的手风琴效果。 上效果图: ![watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_