Is vue-router a good way to get the absolute URL? #2040
-
Hey people, TL;DR: Is Vue Router a good option to replace I am working on a project where we need to read html snipped from a file. This is an <b>example</b> for such a <a href="#" data-dialog-id="TAC">snippet</a> My task is to replace the const snippet = // read from file
const path = this.$route.path
const href = `${window.location.origin}${window.location.pathname}${window.location.search}#${path}?dialog=TAC`
snippet = snippet.replace('href="#"',`href="${href}"`) After this the result anchor will look like this: I wish I could use Since I'm basically simply adding a query param to the current route, I'm wondering if there is a way to simply add a query param to the very current route. It is important that I preserve the path under which my app is running. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
This sounds more like a plain one time js task, so I think it makes more sense to use the web and rely on |
Beta Was this translation helpful? Give feedback.
This sounds more like a plain one time js task, so I think it makes more sense to use the web and rely on
window.location
. Vue Router gives you a reactive location that can be used in your Vue app