NewsList.vue 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <template>
  2. <li v-if="newsData" @click.prevent="checkInfo(newsData)">
  3. <div class="newsInfor-img-box" :style="{backgroundImage: `url(${newsData.cover || newsInforImg})`}"></div>
  4. <div class="newsInfor-list-content">
  5. <h5>{{newsData.title}}</h5>
  6. <div><i></i><span>{{newsData.createDate}}</span></div>
  7. <p v-html="newsData.content"></p>
  8. <a :href="`${baseUrl}/news/${newsData.id}`" >
  9. <span>查看详情</span>
  10. </a>
  11. </div>
  12. </li>
  13. </template>
  14. <script>
  15. import { mapGetters } from 'vuex';
  16. export default {
  17. name: 'NewList',
  18. props: {
  19. newsData: {
  20. type: Object,
  21. default: () => {
  22. },
  23. },
  24. },
  25. data() {
  26. return {
  27. newsInforImg: require(`~/static/images/website/new/new-img.png`),
  28. };
  29. },
  30. computed: {
  31. baseUrl() {
  32. return this.getBaseUrl;
  33. },
  34. ...mapGetters(['getBaseUrl']),
  35. },
  36. methods: {
  37. checkInfo(data) {
  38. // console.log(window.localtion.href);
  39. // console.log(self.localtion.href);
  40. // console.log(document.URL);
  41. const opt = {
  42. id: data.id,
  43. };
  44. this.$router.push({ name: 'news-id', params: opt });
  45. this.$emit('know-more', data);
  46. },
  47. },
  48. };
  49. </script>
  50. <style scoped>
  51. </style>