index.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <template>
  2. <div class="l_layout">
  3. <div class="article" v-for="article in news" :key="article.id">
  4. <img :src="'http://www.4dage.com' + article.cover" alt="">
  5. <div>
  6. <h2>{{article.title}}</h2>
  7. <span>
  8. <template v-if="article.origin">来源:{{article.origin}} &nbsp;|&nbsp;</template>
  9. {{new Date(Number(article.date)).format('yyyy-MM-dd')}} 发表
  10. </span>
  11. <p>{{article.brief}}</p>
  12. <a :href="'#/information/news/' + article.id">阅读全文>></a>
  13. </div>
  14. </div>
  15. </div>
  16. </template>
  17. <script>
  18. export default {
  19. data () {
  20. return {news: []}
  21. },
  22. methods: {
  23. getContent (content) {
  24. let text = content
  25. .replace(/<(style|script|iframe)[^>]*?>[\s\S]+?<\/\1\s*>/gi, '')
  26. .replace(/<[^>]+?>/g, '')
  27. .replace(/\s+/g, ' ')
  28. .replace(/ /g, ' ')
  29. .replace(/&[^>]+?;/g, ' ')
  30. .replace(/>/g, ' ')
  31. return text.substr(0, 320)
  32. }
  33. },
  34. async mounted () {
  35. this.testDom = document.createElement('div')
  36. let result = (await this.$http.get('/news', {params: {page: 0, limit: 100, language: 1}})).data.content
  37. this.news = result.data
  38. }
  39. }
  40. </script>
  41. <style scoped>
  42. .l_layout {
  43. max-width: 1400px;
  44. padding: 0 20px;
  45. margin: 40px auto 80px;
  46. }
  47. .article {
  48. padding-bottom: 30px;
  49. border-bottom: 1px solid #eeeeee;
  50. margin-bottom: 30px;
  51. }
  52. .article img {
  53. width: 100%;
  54. display: block;
  55. }
  56. .article .div {
  57. margin-top: 15px;
  58. }
  59. .article h2 {
  60. font-size: 14px;
  61. color: #171717 ;
  62. margin-top: 18px;
  63. }
  64. .article p,
  65. .article span {
  66. font-size: 12px;
  67. color: #989898;
  68. line-height: 22px;
  69. margin-top: 10px;
  70. }
  71. .article span,
  72. .article a {
  73. display: block;
  74. }
  75. .article a {
  76. margin-top: 10px;
  77. color: #52e2c9;
  78. }
  79. @media screen and (min-width: 950px) {
  80. .article {
  81. padding-left: 330px;
  82. position: relative;
  83. min-height: 240px;
  84. padding-bottom: 40px;
  85. margin-bottom: 40px;
  86. }
  87. .article img {
  88. position: absolute;
  89. top: 0;
  90. left: 0;
  91. width: 300px;
  92. max-height: calc(100% - 40px)
  93. }
  94. .article h2 {
  95. font-size: 18px;
  96. margin-top: 0;
  97. }
  98. .article a,
  99. .article span,
  100. .article p {
  101. margin-top: 20px;
  102. font-size: 14px;
  103. }
  104. }
  105. </style>