entry-client.js
892 Bytes
import Vue from 'vue';
import FastClick from 'fastclick';
import {createApp} from './app';
import yoho from '../public/js/yoho';
import message from '../src/components/message';
import 'statics/scss/common.scss';
import 'statics/font/iconfont.css';
import 'statics/scss/font.scss';
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);
Vue.prop('message', message);
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');
});