main.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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 target="_blank" :href="article.url" v-if="index === 0">
  13. <div class="news-main">
  14. <div class="news-content">
  15. <el-image
  16. class="material-img"
  17. style="width: 100%; height: 120px"
  18. :src="article.picUrl"
  19. />
  20. <div class="news-content-title">
  21. <span>{{ article.title }}</span>
  22. </div>
  23. </div>
  24. </div>
  25. </a>
  26. <!-- 二条/三条等等 -->
  27. <a target="_blank" :href="article.url" v-else>
  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 class="material-img" :src="article.picUrl" height="100%" />
  33. </div>
  34. </div>
  35. </div>
  36. </a>
  37. </div>
  38. </div>
  39. </template>
  40. <script setup lang="ts">
  41. const props = defineProps({
  42. articles: {
  43. type: Array,
  44. default: () => null
  45. }
  46. })
  47. defineExpose({
  48. articles: props.articles
  49. })
  50. </script>
  51. <style lang="scss" scoped>
  52. .news-home {
  53. background-color: #ffffff;
  54. width: 100%;
  55. margin: auto;
  56. }
  57. .news-main {
  58. width: 100%;
  59. margin: auto;
  60. }
  61. .news-content {
  62. background-color: #acadae;
  63. width: 100%;
  64. position: relative;
  65. }
  66. .news-content-title {
  67. display: inline-block;
  68. font-size: 12px;
  69. color: #ffffff;
  70. position: absolute;
  71. left: 0;
  72. bottom: 0;
  73. background-color: black;
  74. width: 98%;
  75. padding: 1%;
  76. opacity: 0.65;
  77. white-space: normal;
  78. box-sizing: unset !important;
  79. }
  80. .news-main-item {
  81. background-color: #ffffff;
  82. padding: 5px 0;
  83. border-top: 1px solid #eaeaea;
  84. }
  85. .news-content-item {
  86. position: relative;
  87. }
  88. .news-content-item-title {
  89. display: inline-block;
  90. font-size: 10px;
  91. width: 70%;
  92. margin-left: 1%;
  93. white-space: normal;
  94. }
  95. .news-content-item-img {
  96. display: inline-block;
  97. width: 25%;
  98. background-color: #acadae;
  99. margin-right: 1%;
  100. }
  101. .material-img {
  102. width: 100%;
  103. }
  104. </style>