Answer the question
In order to leave comments, you need to log in
Why doesn't watch work with document.location?
Hello!
Why doesn't watch work in this case?
There is a computed property that returns the current pathname
getPathName(){
return document.location.pathname;
}
getPathName(news){
console.log(news,document.location.pathname);
}
Answer the question
In order to leave comments, you need to log in
Because watch works on reactive properties. If you want to achieve a reaction to changing route parameters, then watch works on $route.params or fullpath, for example. There are also navigation hooks that are called when changing or following a route. This is all when using vue router, with your router you need to take care of it yourself
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question