vue从一个页面跳转到另一个页面并携带参数的解决方法
- 作者: 华丽的承诺只是敷衍的借口i
- 来源: 51数据库
- 2021-08-07
1.需求:

点击商场跳转到商业体列表

解决方案:
元页面:
a标签中添加跳转函数
<a class="orderbtn1 siricon2" rel="external nofollow" @click="tomallinfo('m000989')"><i class="siricon"></i>商场</a>
tomallinfo: function(mallcode){
this.$router.push({
path: '/propertyinfo/mall/malllist',
// name: 'malllist',
query: {
mallcode: 'm000989'
}
})
},
将将跳转的url添加到 $router中。
path 中的url 最前面加 / 代表是根目录下,不加则是子路由
通过path + query 的组合传递参数
----
跳转页面接收参数
created(){
this.getparams()
},
methods :{getparams(){
// 取到路由带过来的参数
const routerparams = this.$route.query.mallcode
// 将数据放在当前组件的数据内
this.mallinfo.searchmap.mallcode = routerparams;
this.keyupmallname()
}
},
watch: {
'$route': 'getparams'
}
解决!!!
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
推荐阅读
