Going to a URL using VueJS

I'm trying to go to a URL like this:

methods: {
    show (file) {
        this.$router.go('/file/' + file.path + '?token=' + localStorage.getItem('jwt-token'));
    }
}

I'm not trying to go to a component. I just want to go to the following URL:

'/file/' + file.path + '?token=' + localStorage.getItem('jwt-token')

But it does not work. It's redirecting me to the home page.

How can I get this done?


If you want to go to a URL which is not a Vue router URL, you can do it using standard javascript via:

window.location.href = '/file/' + file.path + '?token=' + localStorage.getItem('jwt-token');

See this answer.


这应该在vue路由器2.0中工作:

this.$router.push({path: '/file/' + file.path , query: {token: localStorage.getItem('jwt-token')} })
链接地址: http://www.djcxy.com/p/42196.html

上一篇: 根据另一个下拉列表填充一个下拉列表,然后重定向

下一篇: 使用VueJS访问URL