Vue.js vuejs:有没有办法访问组件内部的router.go()?

Vue.js vuejs:有没有办法访问组件内部的router.go()?,vue.js,Vue.js,我想呼叫路由器。进入组件内部 目前我已经设置了window.router=router//这样代码就可以工作了 index.js const App = Vue.extend(require('./views/app.vue')) router.start(App, '#app') window.router = router // I don't want to set this global variable 导航栏 methods: { search () {

我想呼叫
路由器。进入组件内部

目前我已经设置了
window.router=router
//这样代码就可以工作了

index.js

const App = Vue.extend(require('./views/app.vue'))
router.start(App, '#app')
window.router = router // I don't want to set this global variable
导航栏

methods: {
        search () {
            window.router.go({
                name: 'search',
                query: { q: this.query }
            })
        }
}
methods: {
        search () {
            this.$router.go({
                name: 'search',
                query: { q: this.query }
            })
        }
    }
我要找的是这样的东西,
this.$router.go

导航栏

methods: {
        search () {
            window.router.go({
                name: 'search',
                query: { q: this.query }
            })
        }
}
methods: {
        search () {
            this.$router.go({
                name: 'search',
                query: { q: this.query }
            })
        }
    }

感谢并非常感谢为vue路由器提供的帮助

this.$router.push('path')

对于
vue路由器
1.x

this.$route.router.go('path')

看起来在Vue2中,它现在是
这个。$router
我也将把它添加到我的答案中。