vue使用button带参跳转页面
在使用页面跳转时,经常会遇到参数传递问题,这里使用button按钮进行带参跳转
button按钮
<el-button type="primary" @click="enterFamilyInfo">录入家庭成员信息</el-button>
methods方法:
enterFamilyInfo() {
this.$router.push({path: '/enterFamilyInfo',query:{ index:this.inforform.iden}})
},
子页面在data定义参数类型后,使用 this.$route.query.index接收参数
mounted() {
this.iden = this.$route.query.index
console.log(this.iden);
},
完成!!!!
本文介绍如何在Vue项目中利用button按钮实现页面间带参跳转。通过具体代码示例展示了methods方法中如何设置$router.push来携带参数,并在目标页面通过this.$route.query接收这些参数。
1万+

被折叠的 条评论
为什么被折叠?



