1.需求:
點擊商場跳轉到商業體列表
解決方案:
元頁面:
a標籤中添加跳轉函數
<a class="orderBtn1 sIRicon2" href="javascript:void(0);" @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'
}
解決!!!