watchで下記のように記述し、遷移元と遷移先のpathが異なる場合にtest()が発火する。
watch: {
$route: function (to, from) {
if (to.path !== from.path) {
this.test()
}
},
},
methods: {
test() {
console.log('urlが変わったよ')
}
Go to list of users who liked
Share on X(Twitter)
Share on Facebook
More than 3 years have passed since last update.
watchで下記のように記述し、遷移元と遷移先のpathが異なる場合にtest()が発火する。
watch: {
$route: function (to, from) {
if (to.path !== from.path) {
this.test()
}
},
},
methods: {
test() {
console.log('urlが変わったよ')
}
Register as a new user and use Qiita more conveniently
Go to list of users who liked