最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Going to a URL using VueJS - Stack Overflow

programmeradmin1浏览0评论

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 ponent. 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?

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 ponent. 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?

Share Improve this question edited Nov 10, 2016 at 23:36 jeerbl 7,9075 gold badges26 silver badges39 bronze badges asked Nov 10, 2016 at 17:48 JamieJamie 10.9k35 gold badges109 silver badges199 bronze badges 2
  • 2 vue router 1 or 2? – nils Commented Nov 10, 2016 at 17:53
  • Did you find out? Any of the answers below helped you? – jeerbl Commented Nov 15, 2016 at 11:11
Add a ment  | 

2 Answers 2

Reset to default 5

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.

This should work in vue router 2.0:

this.$router.push({path: '/file/' + file.path , query: {token: localStorage.getItem('jwt-token')} })
发布评论

评论列表(0)

  1. 暂无评论