使用VueJS访问URL
我试图去这样的网址:
methods: {
    show (file) {
        this.$router.go('/file/' + file.path + '?token=' + localStorage.getItem('jwt-token'));
    }
}
我不想去一个组件。 我只想转到以下网址:
'/file/' + file.path + '?token=' + localStorage.getItem('jwt-token')
但它不起作用。 它将我重定向到主页。
我怎样才能做到这一点?
如果您想要转到不是Vue路由器URL的URL,可以通过以下方式使用标准JavaScript来完成:
window.location.href = '/file/' + file.path + '?token=' + localStorage.getItem('jwt-token');
看到这个答案。
这应该在vue路由器2.0中工作:
this.$router.push({path: '/file/' + file.path , query: {token: localStorage.getItem('jwt-token')} })
