collapse.nvue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. <template>
  2. <view>
  3. <text class="example-info">折叠面板用来折叠/显示过长的内容或者是列表。通常是在多内容分类项使用,折叠不重要的内容,显示重要内容。点击可以展开折叠部分。</text>
  4. <view v-for="(item, index) in list" :key="index">
  5. <uni-section :title="item.name" type="line"></uni-section>
  6. <uni-collapse ref="add" class="warp" @change="change">
  7. <uni-collapse-item v-for="(sub, key) in item.data" :key="key" :open="sub.open" :show-animation="sub.showAnimation" :disabled="sub.disabled" :title="sub.subName">
  8. <text class="content">{{ sub.content }}</text>
  9. </uni-collapse-item>
  10. </uni-collapse>
  11. </view>
  12. <uni-section title="手风琴效果" type="line"></uni-section>
  13. <uni-collapse :accordion="true">
  14. <uni-collapse-item v-for="item in accordion" :key="item.id" :title="item.title" :show-animation="item.animation">
  15. <text class="content">{{ item.content }}</text>
  16. </uni-collapse-item>
  17. </uni-collapse>
  18. <uni-section title="配置图标" type="line"></uni-section>
  19. <uni-collapse>
  20. <uni-collapse-item title="标题文字" thumb="https://img-cdn-qiniu.dcloud.net.cn/new-page/uni.png">
  21. <text class="content">折叠内容主体,可自定义内容及样式</text>
  22. </uni-collapse-item>
  23. <uni-collapse-item title="标题文字" thumb="https://img-cdn-qiniu.dcloud.net.cn/new-page/uni.png">
  24. <text class="content">折叠内容主体,可自定义内容及样式</text>
  25. </uni-collapse-item>
  26. </uni-collapse>
  27. </view>
  28. </template>
  29. <script>
  30. export default {
  31. components: {},
  32. data() {
  33. const listData = [{
  34. name: '基础用法',
  35. data: [{
  36. type: false,
  37. subName: '默认开启',
  38. open: true,
  39. content: '折叠内容主体,可自定义内容及样式'
  40. },
  41. {
  42. type: false,
  43. subName: '折叠内容',
  44. content: '折叠内容主体,这是一段比较长内容。默认折叠主要内容,只显示当前项标题。点击标题展开,才能看到这段问题。再次点击标题,折叠内容。'
  45. },
  46. {
  47. type: false,
  48. subName: '禁用状态',
  49. disabled: true,
  50. content: '折叠内容主体,这是一段比较长内容。默认折叠主要内容,只显示当前项标题。点击标题展开,才能看到这段问题。再次点击标题,折叠内容。'
  51. }
  52. ]
  53. },
  54. {
  55. name: '添加动画效果',
  56. data: [{
  57. type: true,
  58. subName: '动画效果',
  59. showAnimation: true,
  60. content: '折叠内容主体,这是一段比较长内容。默认折叠主要内容,只显示当前项标题。点击标题展开,才能看到这段问题。再次点击标题,折叠内容。'
  61. }]
  62. }
  63. ]
  64. return {
  65. list: listData,
  66. accordion: [{
  67. id: 0,
  68. title: '标题文字',
  69. content: '手风琴效果',
  70. animation: true
  71. },
  72. {
  73. id: 1,
  74. title: '标题文字',
  75. content: '手风琴效果',
  76. animation: true
  77. },
  78. {
  79. id: 2,
  80. title: '标题文字',
  81. content: '手风琴效果',
  82. animation: true
  83. }
  84. ],
  85. extraIcon: {
  86. color: '#4cd964',
  87. size: '26',
  88. type: 'image'
  89. },
  90. id: 2
  91. }
  92. },
  93. methods: {
  94. change(e) {}
  95. }
  96. }
  97. </script>
  98. <style>
  99. @charset "UTF-8";
  100. /* 头条小程序组件内不能引入字体 */
  101. /* #ifdef MP-TOUTIAO */
  102. @font-face {
  103. font-family: uniicons;
  104. font-weight: normal;
  105. font-style: normal;
  106. src: url("~@/static/uni.ttf") format("truetype");
  107. }
  108. /* #endif */
  109. /* #ifndef APP-NVUE */
  110. page {
  111. display: flex;
  112. flex-direction: column;
  113. box-sizing: border-box;
  114. background-color: #efeff4;
  115. min-height: 100%;
  116. height: auto;
  117. }
  118. view {
  119. font-size: 14px;
  120. line-height: inherit;
  121. }
  122. .example {
  123. padding: 0 15px 15px;
  124. }
  125. .example-info {
  126. padding: 15px;
  127. color: #3b4144;
  128. background: #ffffff;
  129. }
  130. .example-body {
  131. /* #ifndef APP-NVUE */
  132. display: flex;
  133. /* #endif */
  134. flex-direction: row;
  135. flex-wrap: wrap;
  136. justify-content: center;
  137. padding: 0;
  138. font-size: 14px;
  139. background-color: #ffffff;
  140. }
  141. /* #endif */
  142. .example {
  143. padding: 0 15px;
  144. }
  145. .example-info {
  146. /* #ifndef APP-NVUE */
  147. display: block;
  148. /* #endif */
  149. padding: 15px;
  150. color: #3b4144;
  151. background-color: #ffffff;
  152. font-size: 14px;
  153. line-height: 20px;
  154. }
  155. .example-info-text {
  156. font-size: 14px;
  157. line-height: 20px;
  158. color: #3b4144;
  159. }
  160. .example-body {
  161. flex-direction: column;
  162. padding: 15px;
  163. background-color: #ffffff;
  164. }
  165. .word-btn-white {
  166. font-size: 18px;
  167. color: #FFFFFF;
  168. }
  169. .word-btn {
  170. /* #ifndef APP-NVUE */
  171. display: flex;
  172. /* #endif */
  173. flex-direction: row;
  174. align-items: center;
  175. justify-content: center;
  176. border-radius: 6px;
  177. height: 48px;
  178. margin: 15px;
  179. background-color: #007AFF;
  180. }
  181. .word-btn--hover {
  182. background-color: #4ca2ff;
  183. }
  184. .example-body {
  185. flex-direction: column;
  186. flex: 1;
  187. }
  188. .content {
  189. padding: 15px;
  190. font-size: 14px;
  191. line-height: 20px;
  192. background-color: #f9f9f9;
  193. color: #666;
  194. }
  195. .button {
  196. font-size: 26rpx;
  197. line-height: 90rpx;
  198. }
  199. </style>