vuejs / vue-hackernews-2.0

HackerNews clone built with Vue 2.0, vue-router & vuex, with server-side rendering
MIT License
10.96k stars 2.15k forks source link

Progress bar and page response are not synchronized #335

Closed wwqhy closed 6 years ago

wwqhy commented 6 years ago

router.beforeResolve((to, from, next) => { const matched = router.getMatchedComponents(to) const prevMatched = router.getMatchedComponents(from) let diffed = false const activated = matched.filter((c, i) => { return diffed || (diffed = (prevMatched[i] !== c)) }) const asyncDataHooks = activated.map(c => c.asyncData).filter( => ) if (!asyncDataHooks.length) { return next() } bar.start() Promise.all(asyncDataHooks.map(hook => hook({ store, route: to }))) .then(() => { bar.finish() next() }) .catch(next) })

The above is the client code.My problem is that the top progress bar and page response are not synchronized.thanks.