router.onReady(() => app.$mount('#app'))
// wait until router has resolved possible async hooks router.onReady(() => { const matchedComponents = router.getMatchedComponents() // no matched routes if (!matchedComponents.length) { return reject({ code: 404 }) } const asyncDataHooks = matchedComponents.map((component: any) => { // console.log(component) const asyncData = findAsyncDataFunction(component) // console.log(asyncData) if (asyncData) { return asyncData({ store, route: router.currentRoute, api }) } }) Promise.all(asyncDataHooks) .then(() => { // isDev && console.log(`data pre-fetch: ${Date.now() - s}ms`) context.state = store.state resolve(app) }) .catch(reject) }, reject)
router.onReady(() => { let matchedComponents = router.getMatchedComponents()
router.onReady(() => { router.beforeEach((to, from, next) => { if (to.fullPath.includes('/me')) {
router.onReady(() => {
router.onReady(() => { const matchedComponents = router.getMatchedComponents();
// wait until router has resolved possible async components and hooks router.onReady(() => { const matchedComponents = router.getMatchedComponents(); // no matched routes, reject with 404 if (!matchedComponents.length) { return reject({ code: 404 }); } // This `rendered` hook is called when the app has finished rendering context.rendered = () => { // After the app is rendered, our store is now // filled with the state from our components. // When we attach the state to the context, and the `template` option // is used for the renderer, the state will automatically be // serialized and injected into the HTML as `window.__INITIAL_STATE__`. context.state = store.state; }; // the Promise should resolve to the app instance so it can be rendered resolve(app); }, reject);
router.onReady(() => { app.$mount('#app'); });