blob: 01326f3b5de3e0623e7baf79f2e11cee191e1618 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
import Vue from 'vue';
import VueRouter from 'vue-router';
Vue.use(VueRouter);
export default (currentPath, currentTab = null) => {
// If navigating directly to a tab, determine the base
// path to initialize router, then set the current route.
const base = currentPath.replace(new RegExp(`/${currentTab}$`), '');
const router = new VueRouter({
mode: 'history',
base,
routes: [{ path: '/:tabId', name: 'tab' }],
});
if (currentTab) router.push(`/${currentTab}`);
return router;
};
|