News.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <template>
  2. <div class="news">
  3. <div class="news-container container">
  4. <h2 class="title">
  5. <nuxt-link to="/news">优软快讯</nuxt-link>
  6. </h2>
  7. <ul class="title-list">
  8. <li v-for="n in news5" class="item">
  9. <nuxt-link :to="`/news/${n.id}`">
  10. {{ n.title }}
  11. </nuxt-link>
  12. </li>
  13. <li class="item item-last"><nuxt-link to="/news">查看更多&gt;&gt;</nuxt-link></li>
  14. </ul>
  15. <ul class="thumbnail-list">
  16. <li v-for="n in news3" class="item">
  17. <nuxt-link :to="`/news/${n.id}`">
  18. <img :src="n.thumbnail">
  19. <span>{{ n.title }}</span>
  20. </nuxt-link>
  21. </li>
  22. </ul>
  23. <div class="clearfix"></div>
  24. </div>
  25. </div>
  26. </template>
  27. <script>
  28. export default {
  29. name: 'news',
  30. computed: {
  31. news () {
  32. return this.$store.state.news.snapshot
  33. },
  34. news3 () {
  35. return this.news.data.slice(0, 3)
  36. },
  37. news5 () {
  38. return this.news.data.slice(0, 5)
  39. }
  40. }
  41. }
  42. </script>
  43. <style lang="scss" scoped>
  44. .news {
  45. height: 280px;
  46. background: url("/images/news/news-bg.jpg");
  47. .news-container {
  48. .title {
  49. padding: 20px 0 15px 0;
  50. margin: 0;
  51. }
  52. a {
  53. color: #fff;
  54. &:hover {
  55. color: #feb900;
  56. }
  57. }
  58. .title-list {
  59. width: 450px;
  60. float: left;
  61. .item {
  62. line-height: 25px;
  63. a {
  64. display: inline-block;
  65. width: 100%;
  66. text-overflow: ellipsis;
  67. overflow: hidden;
  68. white-space: nowrap;
  69. }
  70. &:last-child a, .item-last a{
  71. color: #feb900;
  72. }
  73. }
  74. }
  75. .thumbnail-list {
  76. float: right;
  77. .item {
  78. display: inline-block;
  79. position: relative;
  80. margin-left: 15px;
  81. background: #fff;
  82. overflow: hidden;
  83. width: 220px;
  84. height: 190px;
  85. a {
  86. img {
  87. width: 220px;
  88. height: 152px;
  89. }
  90. span {
  91. position: absolute;
  92. left: 0;
  93. right: 0;
  94. bottom: 0;
  95. display: block;
  96. line-height: 38px;
  97. padding: 0 10px;
  98. color: #666;
  99. text-overflow: ellipsis;
  100. overflow: hidden;
  101. white-space: nowrap;
  102. }
  103. &:hover {
  104. img {
  105. transform: scale(1.15);
  106. }
  107. span {
  108. line-height: 28px;
  109. color: #feb900;
  110. }
  111. }
  112. }
  113. }
  114. }
  115. }
  116. }
  117. </style>