Vue single page F5 refresh, how to get the current routing address

console.log (this.$router.path) can"t get, undefined

Mar.17,2021

is this.$route.path , not this.$router.path ;
using vue-router is router , and obtaining the relevant route is route ;


window.location.pathname learn about


add an name attribute to all your configured routes
get name

< hr class= "answer.

watch: {

$route() {
    console.log(this.$route.path)
}

}
this way you can get it, and sometimes this.$route.path can't get the exact

.
Menu