Support retrieving route params

This commit is contained in:
Pig Fang 2018-08-12 17:33:30 +08:00
parent 85d9677a64
commit 96af04433c
2 changed files with 14 additions and 7 deletions

View File

@ -12,10 +12,15 @@ if (process.env.NODE_ENV === 'development') {
setTimeout(langs.find(({ lang }) => lang === blessing.locale).load, 0);
}
const route = routes.find(route => route.path === blessing.route);
if (route) {
new Vue({
el: route.el,
render: h => h(route.component)
});
}
(() => {
const route = routes.find(
route => (new RegExp(`^${route.path}$`, 'i')).test(blessing.route)
);
if (route) {
Vue.prototype.$route = (new RegExp(`^${route.path}$`, 'i')).exec(blessing.route);
new Vue({
el: route.el,
render: h => h(route.component)
});
}
})();

View File

@ -23,5 +23,7 @@ declare module 'vue/types/vue' {
post(url: string, data?: object): { errno?: number, msg?: string }
}
$route: string[]
}
}