list.nvue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. <template>
  2. <view>
  3. <text class="example-info">列表组件可以在其中使用图标、略缩图或放置任何你想放的元素,使用场景如:导航菜单、列表、设置中心排版等</text>
  4. <uni-section title="基础用法" type="line"></uni-section>
  5. <uni-list>
  6. <uni-list-item title="列表文字" rightText="右侧文字" />
  7. <uni-list-item title="列表文字" note="列表描述信息" rightText="右侧文字" />
  8. </uni-list>
  9. <uni-section title="禁用列表" type="line"></uni-section>
  10. <uni-list>
  11. <uni-list-item :disabled="true" title="列表禁用状态" rightText="右侧文字" />
  12. </uni-list>
  13. <uni-section title="展示箭头" type="line"></uni-section>
  14. <uni-list>
  15. <uni-list-item showArrow title="列表文字" />
  16. <uni-list-item showArrow title="列表文字" rightText="右侧文字" />
  17. </uni-list>
  18. <uni-section title="点击反馈" type="line"></uni-section>
  19. <uni-list>
  20. <uni-list-item title="弹窗提示" clickable @click="onClick" />
  21. <uni-list-item title="页面跳转" :to="`./chat`" @click="onClick" />
  22. <uni-list-item title="关闭当前页面打开新页面" link="redirectTo" to="./chat" @click="onClick" />
  23. <uni-list-item title="打开错误页面(查看控制台)" link="redirectTo" to="./chats" @click="onClick" />
  24. </uni-list>
  25. <uni-section title="不显示分割线" type="line"></uni-section>
  26. <uni-list :border="false">
  27. <uni-list-item title="列表文字" />
  28. <uni-list-item :border="false" title="列表文字" note="列表描述信息" rightText="右侧文字" />
  29. <uni-list-item :border="true" title="列表文字" note="列表描述信息" rightText="右侧文字" />
  30. </uni-list>
  31. <uni-section title="文字溢出隐藏" type="line"></uni-section>
  32. <uni-list>
  33. <uni-list-item :ellipsis="1" title="列表 title 超长文字显示一行,以下是测试文字以下是测试文字以下是测试文字以下是测试文字以下是测试文字以下是测试文字" showArrow rightText="右侧文字" />
  34. <uni-list-item :ellipsis="2" title="列表 title 超长文字显示二行,以下是测试文字以下是测试文字以下是测试文字以下是测试文字以下是测试文字以下是测试文字" showArrow rightText="右侧文字" />
  35. <uni-list-item title="列表 title 全部显示,以下是测试文字以下是测试文字以下是测试文字以下是测试文字以下是测试文字以下是测试文字" showArrow rightText="右侧文字" />
  36. </uni-list>
  37. <uni-section title="显示图标或图片" type="line"></uni-section>
  38. <uni-list>
  39. <uni-list-item title="列表左侧带略缩图" note="列表描述信息" showArrow thumb="https://img-cdn-qiniu.dcloud.net.cn/new-page/uni.png" thumb-size="sm" rightText="小图" />
  40. <uni-list-item title="列表左侧带略缩图" note="列表描述信息" showArrow thumb="https://img-cdn-qiniu.dcloud.net.cn/new-page/uni.png" thumb-size="base" rightText="默认" />
  41. <uni-list-item title="列表左侧带略缩图" note="列表描述信息" showArrow thumb="https://img-cdn-qiniu.dcloud.net.cn/new-page/uni.png" thumb-size="lg" rightText="大图" />
  42. <uni-list-item :show-extra-icon="true" showArrow :extra-icon="extraIcon" title="列表左侧带扩展图标" />
  43. </uni-list>
  44. <uni-section title="右侧显示 switch/badge" type="line"></uni-section>
  45. <uni-list>
  46. <uni-list-item :show-extra-icon="true" :extra-icon="extraIcon" :show-badge="true" badge-text="99" showArrow title="禁用状态" @switchChange="switchChange" />
  47. <uni-list-item :show-extra-icon="true" :extra-icon="extraIcon" :show-switch="true" title="列表右侧带 switch" @switchChange="switchChange" />
  48. <uni-list-item :disabled="true" :show-extra-icon="true" :extra-icon="extraIcon" :show-switch="true" :switch-checked="true" title="禁用状态" @switchChange="switchChange" />
  49. </uni-list>
  50. <uni-section title="使用插槽" type="line"></uni-section>
  51. <uni-list>
  52. <uni-list-item>
  53. <view slot="body" class="slot-box">
  54. <text class="slot-text">默认插槽</text>
  55. <uni-badge text="2" type="primary" />
  56. </view>
  57. </uni-list-item>
  58. <uni-list-item title="自定义右侧插槽" note="列表描述信息" link>
  59. <template slot="header">
  60. <image class="slot-image" src="/static/logo.png" mode="widthFix"></image>
  61. </template>
  62. </uni-list-item>
  63. <uni-list-item>
  64. <view slot="header" class="slot-box">
  65. <image class="slot-image" src="/static/logo.png" mode="widthFix"></image>
  66. </view>
  67. <text slot="body" class="slot-box slot-text">自定义左侧插槽</text>
  68. <template slot="footer">
  69. <image class="slot-image" src="/static/logo.png" mode="widthFix"></image>
  70. </template>
  71. </uni-list-item>
  72. </uni-list>
  73. <uni-section title="列表扩展" type="line"></uni-section>
  74. <uni-list>
  75. <uni-list-item title="聊天列表" link :to="`./chat`" @click="onClick($event,1)" />
  76. </uni-list>
  77. </view>
  78. </template>
  79. <script>
  80. export default {
  81. components: {},
  82. data() {
  83. return {
  84. extraIcon: {
  85. color: '#4cd964',
  86. size: '22',
  87. type: 'gear-filled'
  88. }
  89. };
  90. },
  91. methods: {
  92. onClick(e) {
  93. console.log('执行click事件', e.data)
  94. uni.showToast({
  95. title: '点击反馈'
  96. });
  97. },
  98. switchChange(e) {
  99. uni.showToast({
  100. title: 'change:' + e.value,
  101. icon: 'none'
  102. });
  103. }
  104. }
  105. };
  106. </script>
  107. <style>
  108. @charset "UTF-8";
  109. /* 头条小程序组件内不能引入字体 */
  110. /* #ifdef MP-TOUTIAO */
  111. @font-face {
  112. font-family: uniicons;
  113. font-weight: normal;
  114. font-style: normal;
  115. src: url("~@/static/uni.ttf") format("truetype");
  116. }
  117. /* #endif */
  118. /* #ifndef APP-NVUE */
  119. page {
  120. display: flex;
  121. flex-direction: column;
  122. box-sizing: border-box;
  123. background-color: #efeff4;
  124. min-height: 100%;
  125. height: auto;
  126. }
  127. view {
  128. font-size: 14px;
  129. line-height: inherit;
  130. }
  131. .example {
  132. padding: 0 15px 15px;
  133. }
  134. .example-info {
  135. padding: 15px;
  136. color: #3b4144;
  137. background: #ffffff;
  138. }
  139. .example-body {
  140. /* #ifndef APP-NVUE */
  141. display: flex;
  142. /* #endif */
  143. flex-direction: row;
  144. flex-wrap: wrap;
  145. justify-content: center;
  146. padding: 0;
  147. font-size: 14px;
  148. background-color: #ffffff;
  149. }
  150. /* #endif */
  151. .example {
  152. padding: 0 15px;
  153. }
  154. .example-info {
  155. /* #ifndef APP-NVUE */
  156. display: block;
  157. /* #endif */
  158. padding: 15px;
  159. color: #3b4144;
  160. background-color: #ffffff;
  161. font-size: 14px;
  162. line-height: 20px;
  163. }
  164. .example-info-text {
  165. font-size: 14px;
  166. line-height: 20px;
  167. color: #3b4144;
  168. }
  169. .example-body {
  170. flex-direction: column;
  171. padding: 15px;
  172. background-color: #ffffff;
  173. }
  174. .word-btn-white {
  175. font-size: 18px;
  176. color: #FFFFFF;
  177. }
  178. .word-btn {
  179. /* #ifndef APP-NVUE */
  180. display: flex;
  181. /* #endif */
  182. flex-direction: row;
  183. align-items: center;
  184. justify-content: center;
  185. border-radius: 6px;
  186. height: 48px;
  187. margin: 15px;
  188. background-color: #007AFF;
  189. }
  190. .word-btn--hover {
  191. background-color: #4ca2ff;
  192. }
  193. .slot-box {
  194. /* #ifndef APP-NVUE */
  195. display: flex;
  196. /* #endif */
  197. flex-direction: row;
  198. align-items: center;
  199. }
  200. .slot-image {
  201. /* #ifndef APP-NVUE */
  202. display: block;
  203. /* #endif */
  204. margin-right: 10px;
  205. width: 30px;
  206. height: 30px;
  207. }
  208. .slot-text {
  209. flex: 1;
  210. font-size: 14px;
  211. color: #4cd964;
  212. margin-right: 10px;
  213. }
  214. </style>