imgCardLv1.vue 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <template>
  2. <div class="mta-card-lv1">
  3. <div class="mta-card-content-pc mta-hidden-xs">
  4. <img :src="img">
  5. <div class="card-info">
  6. <h5>{{title}}</h5>
  7. <p>{{description}}</p>
  8. <div class="mta-card-row" v-for="(rowList,index) in tages" :key="`pc-${index}`">
  9. <template v-for="(des,ind) in rowList">
  10. <!-- 站位div -->
  11. <span v-if="des.empty" :key="ind"></span>
  12. <span :key="ind"><i></i><span>{{des.value}}</span></span>
  13. </template>
  14. </div>
  15. </div>
  16. </div>
  17. <div class="mta-card-content-h5 mta-hidden-sm">
  18. <img src="#">
  19. <div class="card-info"></div>
  20. </div>
  21. </div>
  22. </template>
  23. <script>
  24. export default {
  25. name: "imgCardLv1",
  26. props: {
  27. img: {
  28. type: String,
  29. required: true,
  30. },
  31. option: {
  32. type: Object,
  33. required: true,
  34. },
  35. col: {
  36. type: Number,
  37. default: 3
  38. }
  39. },
  40. computed: {
  41. title() {
  42. return this.option.title;
  43. },
  44. description() {
  45. return this.option.des;
  46. },
  47. tages() {
  48. const count = this.col;
  49. const list = this.option.list;
  50. const row = Math.ceil(list.length / count);
  51. const result = [];
  52. for (let i = 1; i <= row; i++) {
  53. const start = (i - 1) * count;
  54. const end = (i * count)
  55. const curList = list.slice(start, end);
  56. if (curList.length < count) {
  57. curList.push({type: 'empty'});
  58. }
  59. result.push(curList)
  60. }
  61. }
  62. }
  63. }
  64. </script>
  65. <style scoped>
  66. </style>