main.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <!--
  2. - Copyright (C) 2018-2019
  3. - All rights reserved, Designed By www.joolun.com
  4. 【微信消息 - 图文】
  5. 芋道源码:
  6. ① 代码优化,补充注释,提升阅读性
  7. -->
  8. <template>
  9. <div class="news-home">
  10. <div v-for="(article, index) in articles" :key="index" class="news-div">
  11. <!-- 头条 -->
  12. <a v-if="index === 0" :href="article.url" target="_blank">
  13. <div class="news-main">
  14. <div class="news-content">
  15. <el-image
  16. :src="article.picUrl"
  17. class="material-img"
  18. style="width: 100%; height: 120px"
  19. />
  20. <div class="news-content-title">
  21. <span>{{ article.title }}</span>
  22. </div>
  23. </div>
  24. </div>
  25. </a>
  26. <!-- 二条/三条等等 -->
  27. <a v-else :href="article.url" target="_blank">
  28. <div class="news-main-item">
  29. <div class="news-content-item">
  30. <div class="news-content-item-title">{{ article.title }}</div>
  31. <div class="news-content-item-img">
  32. <img :src="article.picUrl" class="material-img" height="100%" />
  33. </div>
  34. </div>
  35. </div>
  36. </a>
  37. </div>
  38. </div>
  39. </template>
  40. <script lang="ts" name="WxNews" setup>
  41. const props = withDefaults(
  42. defineProps<{
  43. articles: any[] | null
  44. }>(),
  45. {
  46. articles: null
  47. }
  48. )
  49. defineExpose({
  50. articles: props.articles
  51. })
  52. </script>
  53. <style lang="scss" scoped>
  54. .news-home {
  55. width: 100%;
  56. margin: auto;
  57. background-color: #fff;
  58. }
  59. .news-main {
  60. width: 100%;
  61. margin: auto;
  62. }
  63. .news-content {
  64. position: relative;
  65. width: 100%;
  66. background-color: #acadae;
  67. }
  68. .news-content-title {
  69. position: absolute;
  70. bottom: 0;
  71. left: 0;
  72. display: inline-block;
  73. width: 98%;
  74. padding: 1%;
  75. font-size: 12px;
  76. color: #fff;
  77. white-space: normal;
  78. background-color: black;
  79. opacity: 0.65;
  80. box-sizing: unset !important;
  81. }
  82. .news-main-item {
  83. padding: 5px 0;
  84. background-color: #fff;
  85. border-top: 1px solid #eaeaea;
  86. }
  87. .news-content-item {
  88. position: relative;
  89. }
  90. .news-content-item-title {
  91. display: inline-block;
  92. width: 70%;
  93. margin-left: 1%;
  94. font-size: 10px;
  95. white-space: normal;
  96. }
  97. .news-content-item-img {
  98. display: inline-block;
  99. width: 25%;
  100. margin-right: 1%;
  101. background-color: #acadae;
  102. }
  103. .material-img {
  104. width: 100%;
  105. }
  106. </style>