1.需求:
點擊商場跳轉到商業體列表
解決方案:
元頁面:
a標簽中添加跳轉函數
<a class="orderBtn1 sIRicon2" href="javascript:void(0);" @click="toMallInfo('M000989')"><i class="sIRicon"></i>商場</a>
1 toMallInfo: function(mallCode){ 2 this.$router.push({ 3 path: '/propertyInfo/mall/mallList', 4 // name: 'mallList', 5 query: { 6 mallCode: 'M000989' 7 } 8 }) 9 },
將將跳轉的url添加到 $router中。
path 中的url 最前面加 / 代表是根目錄下,不加則是子路由
通過path + query 的組合傳遞參數
----
跳轉頁面接收參數
1 created(){ 2 this.getParams() 3 }, 4 methods :{getParams(){ 5 // 取到路由帶過來的參數 6 const routerParams = this.$route.query.mallCode 7 // 將數據放在當前組件的數據內 8 this.mallInfo.searchMap.mallCode = routerParams; 9 this.keyupMallName() 10 } 11 }, 12 watch: { 13 '$route': 'getParams' 14 }
解決!!!