1.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <template>
  2. <div class="listNewsBox">
  3. <!-- 样式1 -->
  4. <div class="newsListSector" v-if="componentStyle == 1">
  5. <div class="content" v-for="item in listData.slice(0, 10)">
  6. <NuxtLink :href="getLinkPathDetail(item)" :title="item.title"
  7. :target="item.islink == 1 ? '_blank' : '_self'">
  8. <span class="title">{{ item.title }}</span>
  9. <span class="time">{{ item.updated_at }}</span>
  10. </NuxtLink>
  11. </div>
  12. </div>
  13. <!-- 样式2 -->
  14. <div class="newsListSector" v-if="componentStyle == 2">
  15. <div class="content style2" v-for="item in listData.slice(0, 10)">
  16. <NuxtLink :href="getLinkPathDetail(item)" :title="item.title"
  17. :target="item.islink == 1 ? '_blank' : '_self'">
  18. <span class="title">{{ item.title }}</span>
  19. <span class="time">{{ item.updated_at }}</span>
  20. </NuxtLink>
  21. </div>
  22. </div>
  23. <!-- 样式3 -->
  24. <div class="newsListSector" v-if="componentStyle == 3">
  25. <div class="content style3" v-for="item in listData.slice(0, 10)">
  26. <NuxtLink :href="getLinkPathDetail(item)" :title="item.title"
  27. :target="item.islink == 1 ? '_blank' : '_self'">
  28. <span class="title">{{ item.title }}</span>
  29. <span class="time">{{ item.updated_at }}</span>
  30. </NuxtLink>
  31. </div>
  32. </div>
  33. <!-- 样式4 -->
  34. <div class="newsListSector" v-if="componentStyle == 4">
  35. <div class="content style4" v-for="item in listData.slice(0, 10)">
  36. <NuxtLink :href="getLinkPathDetail(item)" :title="item.title"
  37. :target="item.islink == 1 ? '_blank' : '_self'">
  38. <span class="title">{{ item.title }}</span>
  39. <span class="time">{{ item.updated_at }}</span>
  40. </NuxtLink>
  41. </div>
  42. </div>
  43. </div>
  44. </template>
  45. <script setup>
  46. //引入vue
  47. import { ref } from 'vue';
  48. //获得新闻数据
  49. const props = defineProps({
  50. listData: Array,//新闻数据
  51. componentStyle: Number//组件样式
  52. });
  53. </script>
  54. <style lang="less" scoped>
  55. //基本样式 start ---------------------------------------->
  56. .listNewsBox {
  57. .newsListSector {
  58. .content {
  59. width: 100%;
  60. height: 99px;
  61. border-bottom: 1px dashed #cbcbcb;
  62. margin-bottom: 20px;
  63. cursor: pointer;
  64. .title {
  65. display: block;
  66. height: 24px;
  67. line-height: 24px;
  68. color: #333333;
  69. font-size: 18px;
  70. font-weight: bold;
  71. margin-bottom: 25px;
  72. }
  73. .desc {
  74. height: 63px;
  75. line-height: 20px;
  76. color: #666666;
  77. font-size: 18px;
  78. font-family: "Abhaya Libre", serif;
  79. margin-bottom: 20px;
  80. overflow: hidden;
  81. }
  82. .time {
  83. font-family: "Abhaya Libre", serif;
  84. font-size: 18px;
  85. color: #666666;
  86. }
  87. }
  88. // 样式2
  89. .style2 {
  90. border-bottom: 1px solid #cbcbcb;
  91. }
  92. // 样式3
  93. .style3 {
  94. .title {
  95. font-weight: 400;
  96. }
  97. }
  98. // 样式4
  99. .style4 {
  100. border-bottom: 1px solid #cbcbcb;
  101. .title {
  102. font-weight: 400;
  103. }
  104. }
  105. }
  106. }
  107. //基本样式 end ----------------------------------------></style>