Tuesday, April 2, 2019

javascript - 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?


Answer



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.



No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...