怎么在script setup语法糖中使用beforeRouteEnter?
使用不了,因为这个钩子,在setup之前被调用。
官网解释:
beforeRouteEnter
守卫 不能 访问this
,因为守卫在导航确认前被调用,因此即将登场的新组件还没被创建。
先执行这个钩子,确认后才会加载组件,才会调用setup。所以setup内部是别想了。
@jyk0011 @lizaiya Maybe you can see https://github.com/vuejs/rfcs/discussions/302#discussioncomment-1629410
It work for me.