mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-17 19:25:13 +00:00
18 lines
341 B
JavaScript
18 lines
341 B
JavaScript
|
export default function ({ app, error }) {
|
||
|
app.router.beforeEach((to, from, next) => {
|
||
|
if (to.path !== '/router-guard-error') {
|
||
|
return next()
|
||
|
}
|
||
|
|
||
|
if (to.query.error) {
|
||
|
error(new Error(to.query.error))
|
||
|
}
|
||
|
|
||
|
if (to.query.throw) {
|
||
|
next(new Error(to.query.throw))
|
||
|
} else {
|
||
|
next(false)
|
||
|
}
|
||
|
})
|
||
|
}
|