vue-hackernews-2.0
vue-hackernews-2.0 copied to clipboard
Why did `FETCH_LIST_DATA` action fires twice on page switching?
In file src/entry-client.js
, we have beforeRouteUpdate
mixin:
Vue.mixin({
beforeRouteUpdate (to, from, next) {
const { asyncData } = this.$options
if (asyncData) {
asyncData({
store: this.$store,
route: to
}).then(next).catch(next)
} else {
next()
}
}
})
And in src/views/ItemList.vue
, we have been watching for vue-router's page:
watch: {
page (to, from) {
this.loadItems(to, from)
}
},
And I thought these two code fragments are doing the same thing, is it just for demonstrating or other purposes? Thanks!