entry-client.js
709 Bytes
import Vue from 'vue';
import FastClick from 'fastclick';
import {createApp} from './app';
import yoho from '../public/js/yoho';
FastClick.attach(document.body);
if (process.env.NODE_ENV === 'development') {
yoho.isApp = true;
}
const {app, router, store} = createApp();
if (window.__INITIAL_STATE__) {
store.replaceState(window.__INITIAL_STATE__);
}
Vue.prop('yoho', yoho);
router.onReady(() => {
router.beforeResolve((to, from, next) => {
const matched = router.getMatchedComponents();
Promise.all(matched.map(({asyncData}) =>
asyncData && asyncData({store, router: to})))
.then(next)
.catch(next);
});
app.$mount('#app');
});