mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-19 23:21:09 +00:00
fix(vue-app): set push
on router instance rather than prototype (#8523)
resolves #7479 resolves #8522
This commit is contained in:
parent
b06df71753
commit
8c8793073f
@ -83,12 +83,7 @@ const _routes = recursiveRoutes(router.routes, ' ', _components, 1)
|
|||||||
}
|
}
|
||||||
}).join('\n')%>
|
}).join('\n')%>
|
||||||
|
|
||||||
// TODO: remove in Nuxt 3
|
|
||||||
const emptyFn = () => {}
|
const emptyFn = () => {}
|
||||||
const originalPush = Router.prototype.push
|
|
||||||
Router.prototype.push = function push (location, onComplete = emptyFn, onAbort) {
|
|
||||||
return originalPush.call(this, location, onComplete, onAbort)
|
|
||||||
}
|
|
||||||
|
|
||||||
Vue.use(Router)
|
Vue.use(Router)
|
||||||
|
|
||||||
@ -117,6 +112,12 @@ function decodeObj(obj) {
|
|||||||
export function createRouter () {
|
export function createRouter () {
|
||||||
const router = new Router(routerOptions)
|
const router = new Router(routerOptions)
|
||||||
|
|
||||||
|
// TODO: remove in Nuxt 3
|
||||||
|
const originalPush = router.push
|
||||||
|
router.push = function push (location, onComplete = emptyFn, onAbort) {
|
||||||
|
return originalPush.call(this, location, onComplete, onAbort)
|
||||||
|
}
|
||||||
|
|
||||||
const resolve = router.resolve.bind(router)
|
const resolve = router.resolve.bind(router)
|
||||||
router.resolve = (to, current, append) => {
|
router.resolve = (to, current, append) => {
|
||||||
if (typeof to === 'string') {
|
if (typeof to === 'string') {
|
||||||
|
Loading…
Reference in New Issue
Block a user