导入模块:

import {onBeforeRouteUpdate, useRoute} from "vue-router";

监听路由(刷新整个页面不起作用):

        mounted() { // 组件初始化完成
            let that = this;

            let now_route = "";
            let old_route = "";
            onBeforeRouteUpdate((to, from,) => { // 监听路由变化
                let the = this;
                now_route = to.fullPath;
                old_route = from.fullPath;
                //其他操作
                
            });

        },

-

Logo

前往低代码交流专区

更多推荐