项目场景:
提示:一个路由的前提下面有两个页签,需要进入详情页当中的返回按钮,回到原页面
其实就是进行两个页面的传值
vue
通过路由带参数进行传值
①两个组件 A和B,A组件通过query把orderId传递给B组件(触发事件可以是点击事件、钩子函数等)
②在B组件中获取A组件传递过来的参数
解决方案:
//第一步:组件A created() { if (this.$route.query.tabindex) { this.activeName = this.$route.query.tabindex; } },this.$router.push({ path: "/winBidReg/estate/realEstateSignList/view", query: { id: row.conId, backUrl: "/winBidReg/enterSystem/projectEnterSystem", tabIndex: this.$parent.tabIndex } }); //②在B组件中获取A组件传递过来的参数 const tabindex = this.$route.query.tabindex; if (tabindex) { this.$router.push({ path: "/winBidReg/signContract/list_view", query: { tabindex: tabindex } }); }