CardList.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <template>
  2. <page-header-wrapper
  3. :tab-list="tabList"
  4. :tab-active-key="tabActiveKey"
  5. :tab-change="(key) => {
  6. this.tabActiveKey = key
  7. }"
  8. content="段落示意:蚂蚁金服务设计平台 ant.design,用最小的工作量,无缝接入蚂蚁金服生态, 提供跨越设计与开发的体验解决方案。"
  9. >
  10. <template v-slot:extraContent>
  11. <div style="width: 155px; margin-top: -20px;"><img style="width: 100%" :src="extraImage" /></div>
  12. </template>
  13. <a-list
  14. rowKey="id"
  15. :grid="{gutter: 24, lg: 3, md: 2, sm: 1, xs: 1}"
  16. :dataSource="dataSource"
  17. class="card-list"
  18. >
  19. <a-list-item slot="renderItem" slot-scope="item">
  20. <template v-if="!item || item.id === undefined">
  21. <a-button class="new-btn" type="dashed">
  22. <a-icon type="plus"/>
  23. 新增产品
  24. </a-button>
  25. </template>
  26. <template v-else>
  27. <a-card :hoverable="true">
  28. <a-card-meta>
  29. <a slot="title">{{ item.title }}</a>
  30. <a-avatar class="card-avatar" slot="avatar" :src="item.avatar" size="large"/>
  31. <div class="meta-content" slot="description">{{ item.content }}</div>
  32. </a-card-meta>
  33. <template class="ant-card-actions" slot="actions">
  34. <a>操作一</a>
  35. <a>操作二</a>
  36. </template>
  37. </a-card>
  38. </template>
  39. </a-list-item>
  40. </a-list>
  41. </page-header-wrapper>
  42. </template>
  43. <script>
  44. const dataSource = []
  45. dataSource.push({})
  46. for (let i = 0; i < 11; i++) {
  47. dataSource.push({
  48. id: i,
  49. title: 'Alipay',
  50. avatar: 'https://gw.alipayobjects.com/zos/rmsportal/WdGqmHpayyMjiEhcKoVE.png',
  51. content: '在中台产品的研发过程中,会出现不同的设计规范和实现方式,但其中往往存在很多类似的页面和组件,这些类似的组件会被抽离成一套标准规范。'
  52. })
  53. }
  54. export default {
  55. name: 'CardList',
  56. data () {
  57. this.tabList = [
  58. { key: 'tab1', tab: '快速开始' },
  59. { key: 'tab2', tab: '产品简介' },
  60. { key: 'tab3', tab: '产品文档' }
  61. ]
  62. return {
  63. tabActiveKey: 'tab1',
  64. extraImage: 'https://gw.alipayobjects.com/zos/rmsportal/RzwpdLnhmvDJToTdfDPe.png',
  65. dataSource
  66. }
  67. },
  68. methods: {
  69. testFun () {
  70. this.$message.info('快速开始被点击!')
  71. }
  72. }
  73. }
  74. </script>
  75. <style lang="less" scoped>
  76. @import "~@/components/index.less";
  77. .card-list {
  78. :deep(.ant-card-body:hover) {
  79. .ant-card-meta-title>a {
  80. color: @primary-color;
  81. }
  82. }
  83. :deep(.ant-card-meta-title) {
  84. margin-bottom: 12px;
  85. &>a {
  86. display: inline-block;
  87. max-width: 100%;
  88. color: rgba(0,0,0,.85);
  89. }
  90. }
  91. :deep(.meta-content) {
  92. position: relative;
  93. overflow: hidden;
  94. text-overflow: ellipsis;
  95. display: -webkit-box;
  96. height: 64px;
  97. -webkit-line-clamp: 3;
  98. -webkit-box-orient: vertical;
  99. margin-bottom: 1em;
  100. }
  101. }
  102. .card-avatar {
  103. width: 48px;
  104. height: 48px;
  105. border-radius: 48px;
  106. }
  107. .ant-card-actions {
  108. background: #f7f9fa;
  109. li {
  110. float: left;
  111. text-align: center;
  112. margin: 12px 0;
  113. color: rgba(0, 0, 0, 0.45);
  114. width: 50%;
  115. &:not(:last-child) {
  116. border-right: 1px solid #e8e8e8;
  117. }
  118. a {
  119. color: rgba(0, 0, 0, .45);
  120. line-height: 22px;
  121. display: inline-block;
  122. width: 100%;
  123. &:hover {
  124. color: @primary-color;
  125. }
  126. }
  127. }
  128. }
  129. .new-btn {
  130. background-color: #fff;
  131. border-radius: 2px;
  132. width: 100%;
  133. height: 188px;
  134. }
  135. </style>