vue現在のパスurlおよびパラメータの取得方法
366 ワード
開発には現在のurlのパラメータを取得する必要がある場合があります
フルurlは
window.location.href
ルーティングパスは
this.$route.path
経路パラメータ
this.$route.params(paramsはパラメータ名)
現在のルーティングの情報を直接watchで傍受することもできます
フルurlは
window.location.href
ルーティングパスは
this.$route.path
経路パラメータ
this.$route.params(paramsはパラメータ名)
現在のルーティングの情報を直接watchで傍受することもできます
watch:{
$route(to, from) {
console.log(window.location.href);
console.log(this.$route.path);
console.log(this.$route.params);
}
}