Guards in vue components do not trigger

using in-component guards in vue does not trigger the guard method when switching routes
vue code is as follows

<template>
<div>
<div>
<router-link to="/beforeone">beforeone</router-link>
<router-link to="/beforetwo">beforetwo</router-link>
<router-link to="/beforethree">beforethree</router-link>
</div>
<div>
<router-view :page="post">
</router-view>
</div>
</div>
</template>
<script>
import Vue from "vue"
import VueRouter from "vue-router"
import Beforeone from "./beforeone.vue"
import Beforetwo from "./beforetwo.vue"
import Beforethree from "./beforethree.vue"
Vue.use(VueRouter)
const router=new VueRouter({
    routes:[
       {
          path:"/beforeone",
          component:Beforeone,
          props:{id:"one"}
       },
       {
          path:"/beforetwo",
          component:Beforetwo,
          props:{id:"two"}
       },
       {
          path:"/beforethree",
          component:Beforethree,
          props:{id:"three"}
       }
    ]
})
export default{
    name:"daohangbefore",
    data(){
      return{
       loading:false,
       post:null
    }
    },
    router,
    beforeRouteEnter(to,from,next){
    console.log(to.params.id)
        next()
    },
    beforeRouteUpdate(to,from,next){
        console.log(to.params.id)
        next()
    },
    beforeRouteLeave(to, from, next) {
    console.log(" beforeRouteLeave !", this)
    const answer = window.confirm("")
    answer ? next() : next(false)
    }
}
</script>

introduced components for example:

<template>
<div>

two

</div> </template> <script> export default{ name:"beforetwo", props:{ page:Object } } } </script>

switching components in the browser does not report an error, but does not trigger the corresponding guard event (nothing is output in the console). Why?

Mar.09,2021

The router defined by

needs to be passed to the new Vue () constructor. In your new Vue (), try writing something like this.

const app = new Vue({
    router,
    render(h) {
        return h(App, {});
    }
});
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3ee43-4f0b3.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3ee43-4f0b3.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?