mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2024-12-27 05:00:48 +08:00
23 lines
504 B
JavaScript
23 lines
504 B
JavaScript
import VueRouter from 'vue-router'
|
|
|
|
export default function createRouter (Vue, routes) {
|
|
const router = new VueRouter({
|
|
mode: 'history',
|
|
routes
|
|
})
|
|
router.beforeEach(function (to, from, next) {
|
|
Vue.prototype.$NLoadingBar.theme = to.params.theme
|
|
if (to.path !== from.path) {
|
|
Vue.prototype.$NLoadingBar.start()
|
|
}
|
|
next()
|
|
})
|
|
|
|
router.afterEach(function (to, from) {
|
|
if (to.path !== from.path) {
|
|
Vue.prototype.$NLoadingBar.finish()
|
|
}
|
|
})
|
|
return router
|
|
}
|