articleList.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. app.component('article-list', {
  2. template: `
  3. <style>
  4. .article-list article{box-shadow:0 0 6px rgba(0, 0, 0, 0.028), 0 0 18px rgba(0, 0, 0, 0.042), 0 0 80px rgba(0, 0, 0, 0.07);border-radius: 5px;width:95%;height:110px;margin:10px auto;display:flex;align-items:center;background:white;padding:5px 10px;}
  5. .article-list article .s-left {height:90px;display:flex;flex-direction:column;width: 100%;}
  6. .article-list article .s-left.image {width: calc(100% - 120px);}
  7. .article-list article .s-left .s-title{font-size: 16px;text-overflow: ellipsis;display: -webkit-box;overflow: hidden;-webkit-box-orient: vertical;-webkit-box-pack: center;-webkit-box-align: center;-webkit-line-clamp: 3;}
  8. .article-list article .s-left .s-time{font-size: 12px;color:#999;margin-top:auto;}
  9. .article-list article .s-right {width:110px;margin-left:auto;}
  10. </style>
  11. <div class="article-list">
  12. <article v-for="item in list" @click="toDetail(item.id)">
  13. <section class="s-left" :class="{image:!!item.header_image}">
  14. <div class="s-title">{{item.title}}</div>
  15. <div class="s-time">{{item.update_time}}</div>
  16. </section>
  17. <section class="s-right" v-if="item.header_image">
  18. <van-image
  19. width="110"
  20. height="85"
  21. fit="cover"
  22. :src="item.header_image"
  23. ></van-image>
  24. </section>
  25. </article>
  26. </div>
  27. `,
  28. data() {
  29. return {}
  30. },
  31. props: {
  32. list: {
  33. type: Array,
  34. default: [],
  35. },
  36. },
  37. methods: {
  38. toDetail(id) {
  39. location.href = "/mobile/article/detail.html?id=" + id;
  40. },
  41. },
  42. });