index.vue 939 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. console.log(this.nowPage)
  31. this.$store.dispatch('newsData/loadAllNews', { page: this.nowPage, pageSize: this.pageSize })
  32. }
  33. }
  34. }
  35. </script>
  36. <style scoped>
  37. body{
  38. font-size: 14px!important;
  39. }
  40. .news-container{
  41. margin-top: 15px;
  42. }
  43. </style>