Tuesday 2 April 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

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...