3.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <template>
  2. <div class="listNewsBox">
  3. <div class="listNewsTitle">
  4. <NuxtLink v-if="titleLink1.cid" :href="getLinkPath(titleLink1)" :title="titleLink1.alias">
  5. <div :class="{ activeTab: activeTab == 0 }" @mouseenter="activeTab = 0">{{ titleLink1.alias }}</div>
  6. </NuxtLink>
  7. <NuxtLink v-if="titleLink2.cid" :href="getLinkPath(titleLink2)" :title="titleLink2.alias">
  8. <div :class="{ activeTab: activeTab == 1 }" @mouseenter="activeTab = 1">{{ titleLink2.alias }}</div>
  9. </NuxtLink>
  10. </div>
  11. <!--样式1-->
  12. <div class="listNewsContent" v-if="componentStyle == 1">
  13. <div class="box1" v-if="activeTab == 0">
  14. <div v-for="item in component_style1_News1Array">
  15. <NuxtLink :href="getLinkPathDetail(item)" :title="item.title"
  16. :target="item.islink == 1 ? '_blank' : '_self'">
  17. <img :src="item.imgurl" alt="">
  18. <span>{{ item.title }}</span>
  19. </NuxtLink>
  20. </div>
  21. </div>
  22. <div class="box1" v-if="activeTab == 1">
  23. <div v-for="item in component_style1_News1Array_1">
  24. <NuxtLink :href="getLinkPathDetail(item)" :title="item.title"
  25. :target="item.islink == 1 ? '_blank' : '_self'">
  26. <img :src="item.imgurl" alt="">
  27. <span>{{ item.title }}</span>
  28. </NuxtLink>
  29. </div>
  30. </div>
  31. </div>
  32. </div>
  33. </template>
  34. <script setup>
  35. //引入vue
  36. import { ref } from 'vue';
  37. //获得新闻数据
  38. const props = defineProps({
  39. titleLink1: Object,//板块1名称
  40. titleLink2: Object,//板块2名称
  41. templateData: Array,//新闻数据
  42. templateData1: Array,//新闻数据
  43. componentStyle: Number,//样式编号
  44. });
  45. //当前选中的tab
  46. const activeTab = ref(0);
  47. const component_style1_News1Array = ref([]);
  48. const component_style1_News1Array_1 = ref([]);
  49. //真实数据
  50. component_style1_News1Array.value = props.templateData.imgnum;
  51. component_style1_News1Array_1.value = props.templateData1.imgnum;
  52. </script>
  53. <style lang="less" scoped>
  54. //基本样式 start ---------------------------------------->
  55. .listNewsBox {
  56. position: relative;
  57. .listNewsTitle {
  58. display: flex;
  59. align-items: flex-start;
  60. justify-content: flex-start;
  61. height: 38px;
  62. margin-bottom: 20px;
  63. div {
  64. height: 35px;
  65. width: 138px;
  66. line-height: 32px;
  67. font-size: 22px;
  68. font-weight: bold;
  69. color: #333333;
  70. cursor: pointer;
  71. overflow: hidden;
  72. text-overflow: ellipsis;
  73. white-space: nowrap;
  74. padding-bottom: 5px;
  75. &.activeTab {
  76. color: #154079;
  77. background: url("http://192.168.1.234:19000/pre/image/png/20251218/1766042138413493.png") bottom left no-repeat;
  78. }
  79. }
  80. }
  81. .listNewsContent {
  82. width: 380px;
  83. height: 268px;
  84. div {
  85. width: 380px;
  86. height: 268px;
  87. position: relative;
  88. a {
  89. color: #fff;
  90. img {
  91. width: 380px;
  92. height: 268px;
  93. }
  94. span {
  95. position: absolute;
  96. bottom: 0;
  97. left: 0;
  98. display: inline-block;
  99. width: 380px;
  100. height: 50px;
  101. line-height: 50px;
  102. font-size: 14px;
  103. padding: 0 10px;
  104. box-sizing: border-box;
  105. color: #fff;
  106. background-color: rgba(0, 0, 0, 0.2);
  107. overflow: hidden;
  108. text-overflow: ellipsis;
  109. white-space: nowrap;
  110. }
  111. }
  112. }
  113. }
  114. }
  115. //基本样式 end ----------------------------------------></style>