需求:点击按钮后要跳转到另一个页面的第二个tab标签页面中
解决:1.在点击按钮上添加点击事件,在methods中给这个事件添加一个跳转的路径(子页面操作)
toTabBar(){//我的事件名字
this.$router.push({
path: '../../weChatCustomer/tabBar',//我要跳转到的路径
query: {
type: 'b',//我需要跳转到的路径的名字
},
});
},
2.找到你要跳转到的页面的代码文件中(主页面操作)
在methods中写一个判断,代码如下
methods: {
upToTab () { //给这个方法随便取个名字
let type = this.$route.query.type
if (type === 'a'){
this.activeName = 'a'
} else if(type === 'b'){
this.activeName = 'b'
}
}//判断需要跳转的是那个标签,如果标签比较多,也是可以的
},
mounted:function(){
this.upToTab()
},//挂载一下
就是这样