您好,欢迎来到谷吧美食网。
搜索
您的当前位置:首页vue从一个页面跳转到另一个页面并携带参数的解决方法

vue从一个页面跳转到另一个页面并携带参数的解决方法

来源:谷吧美食网


1.需求:

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

解决方案:

元页面:

a标签中添加跳转函数

<a class="orderBtn1 sIRicon2" href="javascript:void(0);" rel="external nofollow" @click="toMallInfo('M0009')"><i class="sIRicon"></i>商场</a>
 toMallInfo: function(mallCode){
 this.$router.push({
 path: '/propertyInfo/mall/mallList',
 // name: 'mallList',
 query: {
 mallCode: 'M0009'
 }
 })
 },

将将跳转的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'
 }

解决!!!

Copyright © 2019- gbjl.cn 版权所有

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务