HotNews2.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <template>
  2. <div class="title">
  3. <h4>
  4. 热点资讯
  5. </h4>
  6. </div>
  7. <!-- 列表 -->
  8. <ul class="rightList">
  9. <li v-for="item in hotNewsList">
  10. <NuxtLink :to="`/newsDetail/${item.id}`" target="_blank">
  11. <img class="left hotNewsImg" :src="item.imgurl">
  12. <p class="left">{{ item.title }}</p>
  13. </NuxtLink>
  14. </li>
  15. </ul>
  16. </template>
  17. <script setup>
  18. //获得axios
  19. const nuxtApp = useNuxtApp();
  20. const axios = nuxtApp.$axios;
  21. import { onMounted } from 'vue'
  22. const hotNewsList = ref([])
  23. //获取详情
  24. const getHotNews = async () => {
  25. const response = await axios.get(`/web/getWebsiteArticlett?pageSize=${5}&level=${4}&placeid=${15}`);
  26. hotNewsList.value = response.data;
  27. }
  28. onMounted(() => {
  29. getHotNews()
  30. })
  31. </script>
  32. <style lang="less" scoped>
  33. .title {
  34. width: 380px;
  35. height: 40px;
  36. line-height: 40px;
  37. border-top: 1px solid #139602;
  38. border-bottom: 1px solid #e7e7e7;
  39. background-color: #fbfbfb;
  40. >h4 {
  41. font-family: Microsoft YaHei, Microsoft YaHei;
  42. font-weight: 400;
  43. margin-left: 20px;
  44. font-size: 20px;
  45. color: #000000;
  46. text-align: left;
  47. font-style: normal;
  48. text-transform: none;
  49. >span {
  50. float: right;
  51. font-family: Microsoft YaHei, Microsoft YaHei;
  52. font-weight: 400;
  53. font-size: 14px;
  54. margin-right: 10px;
  55. color: #999999;
  56. text-align: left;
  57. font-style: normal;
  58. text-transform: none;
  59. }
  60. }
  61. }
  62. .rightList {
  63. height: 540px;
  64. padding-top: 20px;
  65. background-color: #fbfbfb;
  66. >li {
  67. height: 100px;
  68. margin-bottom: 10px;
  69. margin-left: 15px;
  70. a {
  71. display: block;
  72. }
  73. >img {
  74. width: 150px;
  75. height: 100px;
  76. border-radius: 4px;
  77. }
  78. p {
  79. width: 216px;
  80. height: 100px;
  81. padding-left: 12px;
  82. padding-right: 10px;
  83. box-sizing: border-box;
  84. font-family: PingFang SC, PingFang SC;
  85. font-weight: 400;
  86. font-size: 16px;
  87. color: #333333;
  88. line-height: 22px;
  89. text-align: left;
  90. font-style: normal;
  91. text-transform: none;
  92. }
  93. }
  94. >li:hover {
  95. p {
  96. box-shadow: 0 0 16px 1px rgba(0, 0, 0, 0.1);
  97. color: #139602;
  98. }
  99. }
  100. }
  101. .hotNewsImg {
  102. width: 150px;
  103. height: 100px;
  104. border-radius: 4px;
  105. }
  106. </style>