newsComp2.vue 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <template>
  2. <div>
  3. <!-- 新闻资讯 PC-->
  4. <div class="platform-news-information mta-hidden-xs">
  5. <!-- 新闻资讯 -->
  6. <div class="client-container">
  7. <h4 class="client-title">新闻资讯</h4>
  8. <ul>
  9. <li style="font-size: 16px" v-for="(item, index) in newsData" :key="index">
  10. <div>
  11. <img :src="item.pic" alt="新闻资讯" />
  12. <h4 @click="checkInfo(item)">{{ item.title }}</h4>
  13. <span>发布时间:{{item.yyyy }}-{{ item.mmdd }}</span>
  14. <p>{{ item.intro }}</p>
  15. </div>
  16. </li>
  17. </ul>
  18. </div>
  19. </div>
  20. <!-- 新闻资讯 手机-->
  21. <div class="client-newsInfo-phone mta-hidden-sm">
  22. <h4 class="client-title">新闻资讯</h4>
  23. <el-carousel :interval="5000" type="card" height="300px" indicator-position="none" arrow="never">
  24. <el-carousel-item v-for="(item,index) in newsData" @click="checkInfo(item)" :key="index" class="el-row">
  25. <img :src="item.pic" alt="新闻资讯"/>
  26. <div class="newsInfo-card-content">
  27. <a style="display: none" :href="`${baseUrl}/news/${item.code}`"></a>
  28. <h4>{{ item.title }}<i></i></h4>
  29. <span>{{ item.yyyy }}-{{ item.mmdd }}</span>
  30. <p>{{ item.intro }}</p>
  31. </div>
  32. </el-carousel-item>
  33. </el-carousel>
  34. </div>
  35. </div>
  36. </template>
  37. <script>
  38. import {mapGetters} from "vuex";
  39. export default {
  40. name: "newsComp",
  41. props: {
  42. newsData: {
  43. type: Array,
  44. default: () => ([])
  45. }
  46. },
  47. data() {
  48. return {
  49. checkIsPc: false,
  50. }
  51. },
  52. computed: {
  53. baseUrl() {
  54. return this.getBaseUrl;
  55. },
  56. ...mapGetters(['getBaseUrl']),
  57. },
  58. methods: {
  59. isPC() {
  60. const browserWidth = document.documentElement.clientWidth;
  61. if (browserWidth <= 768) {
  62. return false;
  63. } else {
  64. return true;
  65. }
  66. },
  67. checkInfo(data) {
  68. const opt = {
  69. id: data.code,
  70. };
  71. this.$router.push({name: 'news-id', params: opt});
  72. }
  73. },
  74. mounted() {
  75. this.checkIsPc = this.isPC();
  76. }
  77. }
  78. </script>
  79. <style scoped>
  80. </style>