index.vue 905 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <template>
  2. <div class="container news-container">
  3. <left></left>
  4. <right @pageEvent="listenChild"></right>
  5. </div>
  6. </template>
  7. <script>
  8. import { Left, Right } from '~components/news'
  9. export default {
  10. layout: 'main',
  11. data () {
  12. return {
  13. pageSize: 10,
  14. nowPage: 1
  15. }
  16. },
  17. fetch ({ store }) {
  18. return Promise.all([
  19. store.dispatch('newsData/loadAllNews', { page: this.nowPage, pageSize: this.pageSize }),
  20. store.dispatch('newsData/loadHotNews')
  21. ])
  22. },
  23. components: {
  24. Left,
  25. Right
  26. },
  27. methods: {
  28. listenChild: function (nPage) {
  29. this.nowPage = nPage
  30. this.$store.dispatch('newsData/loadAllNews', { page: this.nowPage, pageSize: this.pageSize })
  31. }
  32. }
  33. }
  34. </script>
  35. <style scoped>
  36. body{
  37. font-size: 14px!important;
  38. }
  39. .news-container{
  40. margin-top: 15px;
  41. }
  42. </style>