参考链接
https://www.jb51.net/article/167464.htm
方法
b 页面
a标签中添加跳转函数
<a class="orderBtn1 sIRicon2" href="javascript:void(0);" target="_blank" rel="external nofollow" 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 的组合传递参数
a 页面
跳转页面接收参数
created(){
this.getParams()
},
methods :{
getParams(){
const routerParams = this.$route.query.mallCode; // 取到路由带过来的参数
this.mallInfo.searchMap.mallCode = routerParams; // 将数据放在当前组件的数据内
this.keyupMallName();
}
},
watch: {
'$route': 'getParams'
}