1、
watch:{ $route(to,from){ console.log(to.path); } },
2、
watch: { $route: { handler: function(val, oldVal){ console.log(val); }, // 深度观察监听 deep: true } },
3、
watch: { '$route':'getPath' }, methods: { getPath(){ console.log(this.$route.path); } }
2023-10-02 23:47:52
1、
watch:{ $route(to,from){ console.log(to.path); } },
2、
watch: { $route: { handler: function(val, oldVal){ console.log(val); }, // 深度观察监听 deep: true } },
3、
watch: { '$route':'getPath' }, methods: { getPath(){ console.log(this.$route.path); } }