mirror of
https://github.com/youzan/vant.git
synced 2025-10-21 11:17:41 +00:00
[Doc] optimzie router & remove unused code (#640)
This commit is contained in:
41
docs/src/mobile.js
Normal file
41
docs/src/mobile.js
Normal file
@@ -0,0 +1,41 @@
|
||||
import Vue from 'vue';
|
||||
import VueRouter from 'vue-router';
|
||||
import App from './WapApp';
|
||||
import routes from './router';
|
||||
import Vant, { Lazyload } from 'packages';
|
||||
import VantDoc from 'vant-doc';
|
||||
import 'packages/vant-css/src/index.css';
|
||||
import 'packages/vant-css/src/icon-local.css';
|
||||
import 'vant-doc/src/helper/touch-simulator';
|
||||
import './components/nprogress.css';
|
||||
|
||||
Vue
|
||||
.use(Vant)
|
||||
.use(VantDoc)
|
||||
.use(VueRouter)
|
||||
.use(Lazyload, {
|
||||
lazyComponent: true
|
||||
});
|
||||
|
||||
const router = new VueRouter({
|
||||
mode: 'hash',
|
||||
base: '/zanui/vant/mobile',
|
||||
routes: routes(true)
|
||||
});
|
||||
|
||||
router.afterEach(() => {
|
||||
if (router.currentRoute.name) {
|
||||
window.scrollTo(0, 0);
|
||||
}
|
||||
if (!router.currentRoute.redirectedFrom) {
|
||||
Vue.nextTick(() => window.syncPath());
|
||||
}
|
||||
});
|
||||
|
||||
window.vueRouter = router;
|
||||
|
||||
new Vue({ // eslint-disable-line
|
||||
render: h => h(App),
|
||||
router,
|
||||
el: '#app'
|
||||
});
|
Reference in New Issue
Block a user