1、父组件路由传参

this.$router.push({
                 path:'/roomDetail',
                 query:{
                        num:dd
                    }
               })

2、子组件接收

 created () {
            this.routerQuery = this.$route.query.num;
        },

关键部分代码

 watch : {
        routerQuery: function (newValue, oldValue) {
                 this.findPositionByRoom(newValue);
           },
            $route(to, from) {
                 console.log(to.query.num)
                 if(to.query.num != undefined){
                    this.findPositionByRoom(to.query.num);
                 }
             }
        },

以上jingzu

Logo

前往低代码交流专区

更多推荐