index.vue 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <template>
  2. <view class="news-index">
  3. <nav-bar title="新闻" @init="onInitNavbar"></nav-bar>
  4. <u-scroll-view :tabbar-conflict="false">
  5. <view class="main-container">
  6. <u-tabs :active.sync="tabActive" :tabs="tabs" tab-style="default" @change="tabChange"/>
  7. <van-empty v-if="newsList.length === 0" description="暂无数据" />
  8. <view v-else class="news-list">
  9. <template v-for="(item, index) in newsList">
  10. <news-item :item="item" :key="index" />
  11. </template>
  12. </view>
  13. </view>
  14. </u-scroll-view>
  15. </view>
  16. </template>
  17. <script>
  18. import NavBar from '@/components/layout/nav-bar'
  19. import UTabs from '@/components/common/u-tabs'
  20. import UScrollView from '@/components/common/u-scroll-view'
  21. import NewsItem from '@/pages/news/components/news-item.vue'
  22. export default {
  23. options: {
  24. styleIsolation: 'shared'
  25. },
  26. components: {
  27. NavBar,
  28. UTabs,
  29. UScrollView,
  30. NewsItem
  31. },
  32. data() {
  33. return {
  34. tabActive: 'exhibition',
  35. tabs: [{
  36. label: '展会新闻',
  37. value: 'exhibition'
  38. }, {
  39. label: '展商新闻',
  40. value: 'exhibitor'
  41. }],
  42. newsList: [{}, {}, {}, {}, {}, {}]
  43. }
  44. },
  45. onLoad(options) {
  46. if (options.type) {
  47. this.tabActive = options.type
  48. }
  49. },
  50. created() {},
  51. methods: {
  52. tabChange() {
  53. }
  54. }
  55. }
  56. </script>
  57. <style lang="scss">
  58. .news-list{
  59. display: grid;
  60. grid-template-columns: 1fr;
  61. grid-row-gap: 18rpx;
  62. margin-top: 28rpx;
  63. }
  64. </style>