card.nvue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. <template>
  2. <view>
  3. <text class="example-info">卡片组件通用来显示完整独立的一段信息,同时让用户理解他的作用。例如一篇文章的预览图、作者信息、时间等,卡片通常是更复杂和更详细信息的入口点。</text>
  4. <uni-section title="基础卡片" type="line"></uni-section>
  5. <view class="example-body">
  6. <uni-card @click="clickCard"><text class="content-box-text">这是一个基础卡片示例,内容较少,此示例不带边框阴影。</text></uni-card>
  7. <uni-card title="标题文字" isShadow @click="clickCard"><text class="content-box-text">这是一个基础卡片示例,内容比较多,内容样式可自定义,卡片视图常用来显示完整独立的一段信息,比如一篇文章的预览图、作者信息、时间等,此示例带边框阴影。</text></uni-card>
  8. <uni-card title="标题文字" extra="额外信息" isShadow note="Tips" @click="clickCard"><text class="content-box-text">这是一个相对比较完整的基础卡片示例,带有标题、额外信息以及底部信息,内容样式可自定义。</text></uni-card>
  9. </view>
  10. <uni-section title="通栏卡片" type="line"></uni-section>
  11. <view class="example-body">
  12. <view class="example-box">
  13. <uni-card title="标题文字" :isFull="true" isShadow='true' note="额外信息" extra="额外信息" @click="clickCard"><text class="content-box-text">通栏卡片,左右上下没有间距,用户可自定义卡片距离等信息</text></uni-card>
  14. </view>
  15. </view>
  16. <uni-section title="图文卡片" type="line"></uni-section>
  17. <view class="example-body">
  18. <uni-card :is-shadow="true" title="标题文字" mode="style" thumbnail="https://img-cdn-qiniu.dcloud.net.cn/uniapp/images/shuijiao.jpg" extra="额外信息" note="true" @click="clickCard">
  19. <text class="content-box-text">图文卡片支持传入一张图片,在最上方显示,标题作为图片描述,额外信息作为内容标题,通常作用为作者信息或发布时间描述,自行配置是否需要底部信息</text>
  20. <block slot="footer">
  21. <view class="footer-box">
  22. <view class="" @click.stop="footerClick('喜欢')"><text class="footer-box__item">喜欢</text></view>
  23. <view class="" @click.stop="footerClick('评论')"><text class="footer-box__item">评论</text></view>
  24. <view class="" @click.stop="footerClick('分享')"><text class="footer-box__item">分享</text></view>
  25. </view>
  26. </block>
  27. </uni-card>
  28. </view>
  29. <uni-section title="标题卡片" type="line"></uni-section>
  30. <view class="example-body">
  31. <uni-card :isShadow="true" title="标题内容" subTitle="副标题" mode="title" thumbnail="https://img-cdn-qiniu.dcloud.net.cn/new-page/uni.png" extra="技术没有上限" note="true" @click="clickCard">
  32. <view>
  33. <view class="image-box">
  34. <image class="image" mode="aspectFill" src="https://img-cdn-qiniu.dcloud.net.cn/uniapp/images/shuijiao.jpg" />
  35. </view>
  36. <view class="content-box">
  37. <text class="content-box-text">标题卡片带有一个双标题头部,右侧为额外描述信息 ,内容可自定义实现</text>
  38. </view>
  39. </view>
  40. <template slot="footer">
  41. <view class="footer-box">
  42. <view @click.stop="footerClick('喜欢')"><text class="footer-box__item">喜欢</text></view>
  43. <view @click.stop="footerClick('评论')"><text class="footer-box__item">评论</text></view>
  44. <view @click.stop="footerClick('分享')"><text class="footer-box__item">分享</text></view>
  45. </view>
  46. </template>
  47. </uni-card>
  48. </view>
  49. </view>
  50. </template>
  51. <script>
  52. export default {
  53. components: {},
  54. data() {
  55. return {
  56. list: [{
  57. id: 0,
  58. title: '',
  59. content: '',
  60. shadow: false,
  61. note: '',
  62. extra: '',
  63. thumbnail: ''
  64. }, {
  65. id: 1,
  66. title: '标题文字',
  67. content: '',
  68. shadow: true,
  69. note: '',
  70. extra: '额外信息',
  71. thumbnail: ''
  72. }, {
  73. id: 2,
  74. title: '标题文字',
  75. content: '',
  76. shadow: true,
  77. note: 'Tips',
  78. extra: '额外信息',
  79. thumbnail: ''
  80. }, {
  81. id: 3,
  82. title: '标题文字',
  83. content: '这是一个完整配置的基础卡片示例。内容样式可自定义。',
  84. shadow: true,
  85. note: 'Tips',
  86. extra: '额外信息',
  87. thumbnail: 'https://img-cdn-qiniu.dcloud.net.cn/new-page/uni.png'
  88. }],
  89. Tips: ['喜欢', '评论', '分享']
  90. }
  91. },
  92. methods: {
  93. clickCard() {
  94. uni.showToast({
  95. title: '点击卡片',
  96. icon: 'none'
  97. })
  98. },
  99. footerClick(types) {
  100. uni.showToast({
  101. title: types,
  102. icon: 'none'
  103. })
  104. }
  105. }
  106. }
  107. </script>
  108. <style>
  109. @charset "UTF-8";
  110. /* 头条小程序组件内不能引入字体 */
  111. /* #ifdef MP-TOUTIAO */
  112. @font-face {
  113. font-family: uniicons;
  114. font-weight: normal;
  115. font-style: normal;
  116. src: url("~@/static/uni.ttf") format("truetype");
  117. }
  118. /* #endif */
  119. /* #ifndef APP-NVUE */
  120. page {
  121. display: flex;
  122. flex-direction: column;
  123. box-sizing: border-box;
  124. background-color: #efeff4;
  125. min-height: 100%;
  126. height: auto;
  127. }
  128. view {
  129. font-size: 14px;
  130. line-height: inherit;
  131. }
  132. .example {
  133. padding: 0 15px 15px;
  134. }
  135. .example-info {
  136. padding: 15px;
  137. color: #3b4144;
  138. background: #ffffff;
  139. }
  140. .example-body {
  141. /* #ifndef APP-NVUE */
  142. display: flex;
  143. /* #endif */
  144. flex-direction: row;
  145. flex-wrap: wrap;
  146. justify-content: center;
  147. padding: 0;
  148. font-size: 14px;
  149. background-color: #ffffff;
  150. }
  151. /* #endif */
  152. .example {
  153. padding: 0 15px;
  154. }
  155. .example-info {
  156. /* #ifndef APP-NVUE */
  157. display: block;
  158. /* #endif */
  159. padding: 15px;
  160. color: #3b4144;
  161. background-color: #ffffff;
  162. font-size: 14px;
  163. line-height: 20px;
  164. }
  165. .example-info-text {
  166. font-size: 14px;
  167. line-height: 20px;
  168. color: #3b4144;
  169. }
  170. .example-body {
  171. flex-direction: column;
  172. padding: 15px;
  173. background-color: #ffffff;
  174. }
  175. .word-btn-white {
  176. font-size: 18px;
  177. color: #FFFFFF;
  178. }
  179. .word-btn {
  180. /* #ifndef APP-NVUE */
  181. display: flex;
  182. /* #endif */
  183. flex-direction: row;
  184. align-items: center;
  185. justify-content: center;
  186. border-radius: 6px;
  187. height: 48px;
  188. margin: 15px;
  189. background-color: #007AFF;
  190. }
  191. .word-btn--hover {
  192. background-color: #4ca2ff;
  193. }
  194. .example-body {
  195. /* #ifndef APP-NVUE */
  196. display: block;
  197. /* #endif */
  198. padding: 1px 0;
  199. }
  200. .example-box {
  201. margin: 12px 0;
  202. }
  203. .image-box {
  204. /* #ifndef APP-NVUE */
  205. display: flex;
  206. flex-direction: column;
  207. /* #endif */
  208. height: 350rpx;
  209. overflow: hidden;
  210. }
  211. .image {
  212. /* #ifndef APP-NVUE */
  213. width: 100%;
  214. height: 100%;
  215. /* #endif */
  216. flex: 1;
  217. }
  218. .content-box {
  219. padding-top: 20rpx;
  220. }
  221. .content-box-text {
  222. font-size: 12px;
  223. line-height: 22px;
  224. }
  225. .footer-box {
  226. /* #ifndef APP-NVUE */
  227. display: flex;
  228. /* #endif */
  229. justify-content: space-between;
  230. flex-direction: row;
  231. }
  232. .footer-box__item {
  233. align-items: center;
  234. padding: 2px 0;
  235. font-size: 12px;
  236. color: #666;
  237. }
  238. </style>