Is the beforeRouteLeave written in the route or in the component?

Why can"t I output it when I write it in the route? Baidu did not find an example of where to write for a long time.
I think router documents do not have this usage. Did you cancel it? Link description

{
      path: "/add",
      name: "add",
      component: Add,
      beforeRouteLeave (to, from, next) {
        console.log(1)
      }
    }
Feb.25,2022

beforeRouteLeave ide/advanced/navigation-guards.html-sharp%E7%BB%84%E4%BB%B6%E5%86%85%E7%9A%84%E5%AE%88%E5%8D%AB" rel=" nofollow noreferrer "> link description


written in a vue file
clipboard.png


has not been found by Baidu for a long time. The official document is written clearly, so frivolous, write a Mao code ah?

Menu