NewsList.vue 1.3 KB

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