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
2 Answers
Reset to default 5If 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')} })