1、情境
由index页面跳转到detail页面
从detail页面返回时需要给index页面传一个参数tabIndex
2、实现
detail页面:
beforeRouteLeave(to, from, next) { if (to.name == 'Detail') { to.query.tabIndex = "2"; } next(); }
index页面:
mounted() { if (this.$route.query.tabIndex) { this.tabIndex = this.$route.query.tabIndex; } },