index.vue 964 B

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