mirror of
https://github.com/youzan/vant.git
synced 2025-10-21 19:24:16 +00:00
[Doc] update demo
This commit is contained in:
@@ -3,21 +3,24 @@ import VueRouter from 'vue-router';
|
||||
import VantDoc from '@vant/doc';
|
||||
import App from './DocsApp';
|
||||
import routes from './router';
|
||||
import { isMobile } from './utils';
|
||||
import { isMobile, importAll } from './utils';
|
||||
|
||||
if (isMobile) {
|
||||
location.replace('mobile.html' + location.hash);
|
||||
}
|
||||
|
||||
Vue.use(VueRouter).use(VantDoc);
|
||||
|
||||
const docs = {};
|
||||
const docsFromMarkdown = require.context('../markdown', false, /(en-US|zh-CN)\.md$/);
|
||||
const docsFromPackages = require.context('../../packages', true, /(en-US|zh-CN)\.md$/);
|
||||
|
||||
importAll(docs, docsFromMarkdown);
|
||||
importAll(docs, docsFromPackages);
|
||||
|
||||
const router = new VueRouter({
|
||||
mode: 'hash',
|
||||
routes: routes()
|
||||
});
|
||||
|
||||
router.beforeEach((route, redirect, next) => {
|
||||
if (isMobile) {
|
||||
location.replace('mobile.html' + location.hash);
|
||||
}
|
||||
document.title = route.meta.title || document.title;
|
||||
next();
|
||||
routes: routes({ componentMap: docs })
|
||||
});
|
||||
|
||||
router.afterEach(() => {
|
||||
|
Reference in New Issue
Block a user