vant/docs/src/index.js
2018-08-08 15:43:31 +08:00

41 lines
829 B
JavaScript

import Vue from 'vue';
import VueRouter from 'vue-router';
import App from './DocsApp';
import routes from './router';
import VantDoc, { progress } from 'vant-doc';
import { isMobile } from './utils';
Vue.use(VueRouter).use(VantDoc);
const router = new VueRouter({
mode: 'hash',
routes: routes()
});
router.beforeEach((route, redirect, next) => {
if (isMobile) {
location.replace('mobile.html' + location.hash);
}
progress.start();
document.title = route.meta.title || document.title;
next();
});
router.afterEach(() => {
progress.done();
window.scrollTo(0, 0);
Vue.nextTick(() => window.syncPath());
});
window.vueRouter = router;
if (process.env.NODE_ENV !== 'production') {
Vue.config.productionTip = false;
}
new Vue({ // eslint-disable-line
render: h => h(App),
router,
el: '#app'
});