HotNews.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <template>
  2. <div class="title">
  3. <h4>
  4. 热点资讯
  5. </h4>
  6. </div>
  7. <ul class="messageList">
  8. <li v-for="(item,index) in hotNewsList">
  9. <span>{{ index+1 }}</span>
  10. <NuxtLink :to="`/newsDetail/${item.id}`" target="_blank" >{{item.title}}</NuxtLink>
  11. <!-- <NuxtLink>数说新中国75年|人民文化生活日益丰富 文...</NuxtLink> -->
  12. </li>
  13. </ul>
  14. </template>
  15. <script setup>
  16. //获得axios
  17. const nuxtApp = useNuxtApp();
  18. const axios = nuxtApp.$axios;
  19. import { onMounted } from 'vue'
  20. const hotNewsList = ref([])
  21. //获取详情
  22. const getHotNews = async () => {
  23. const response = await axios.get(`/web/getWebsiteArticlett?pageSize=${14}&level=${4}`);
  24. hotNewsList.value = response.data;
  25. }
  26. onMounted(()=>{
  27. getHotNews()
  28. })
  29. </script>
  30. <style lang="less" scoped>
  31. .title {
  32. width: 380px;
  33. height: 40px;
  34. line-height: 40px;
  35. // border-top: 1px solid #139602;
  36. border-bottom: 1px solid #e7e7e7;
  37. background-color: #fbfbfb;
  38. >h4 {
  39. font-family: Microsoft YaHei, Microsoft YaHei;
  40. font-weight: 400;
  41. margin-left: 20px;
  42. font-size: 20px;
  43. color: #000000;
  44. text-align: left;
  45. font-style: normal;
  46. text-transform: none;
  47. >span {
  48. float: right;
  49. font-family: Microsoft YaHei, Microsoft YaHei;
  50. font-weight: 400;
  51. font-size: 14px;
  52. margin-right: 10px;
  53. color: #999999;
  54. text-align: left;
  55. font-style: normal;
  56. text-transform: none;
  57. }
  58. }
  59. }
  60. .messageList {
  61. height: 563px;
  62. padding-top: 15px;
  63. margin-bottom: 30px;
  64. background-color: #fbfbfb;
  65. >li {
  66. height: 24px;
  67. margin-bottom: 16px;
  68. white-space: nowrap; /* 禁止换行 */
  69. overflow: hidden; /* 隐藏超出部分 */
  70. text-overflow: ellipsis; /* 超出部分显示省略号 */
  71. >span {
  72. display: inline-block;
  73. width: 24px;
  74. height: 24px;
  75. margin-left: 22px;
  76. line-height: 24px;
  77. vertical-align: middle;
  78. text-align: center;
  79. background-color: #cecece;
  80. font-family: Microsoft YaHei, Microsoft YaHei;
  81. font-weight: 400;
  82. font-size: 18px;
  83. color: #FFFFFF;
  84. text-align: center;
  85. font-style: normal;
  86. text-transform: none;
  87. }
  88. >a {
  89. width: 256px;
  90. height: 21px;
  91. font-family: Microsoft YaHei, Microsoft YaHei;
  92. font-weight: 400;
  93. font-size: 16px;
  94. color: #333333;
  95. line-height: 19px;
  96. text-align: left;
  97. font-style: normal;
  98. text-transform: none;
  99. padding-left: 10px;
  100. }
  101. }
  102. >li:hover>a {
  103. color: #139602;
  104. }
  105. >li:nth-child(1)>span {
  106. background-color: #00c524;
  107. }
  108. >li:nth-child(2)>span {
  109. background-color: #ffdf27;
  110. }
  111. >li:nth-child(3)>span {
  112. background-color: #f3c57f;
  113. }
  114. }
  115. </style>