main.vue 2.4 KB

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