由于业务需求,版主以新手手速简单实现了一下,当然方法”千百“,版主就取了一条
第一步在跳转页面传出参数:
this.$router.push({
//跳转的页面
path: '/feeling',
//跳转传出的参数
query: {
p_a: this.rule.num,
p_b: this.rule.name,
p_c: this.type
}
})
第二步在跳到的页面接受参数:
export default {
data(){
return {
rule: {
num: '',
name: '',
type: ''
},
}
},
//数据初始化完毕自动调用方法
toParams(){
//获取传入的参数
this.rule.num = this.$route.query.p_a,
this.rule.name = this.$route.query.p_b,
this.type = this.$route.query.p_c
//打出来看看
var params = this.$route.query;
console.log(params)
}
}
这不过这个toParams()方法写的地方注意了。手写的代码不知道有没有写错,工作代码不便贴出。