vue跳转页面携带参数
2019-04-22 16:09
197 查看
2017年的时候使用Vue2.0做过一个系统,之后一直就在做JQuery,巩固了基础和数据库、java 的知识。2019年4月份开始用vue2.x来写,vue的基础的东西还是需要记录一下的。
页面跳转:
HTML:
<span @click="addGoods" class="addGoods">新增进件</span>
Script – methods :
不携带参数直接跳转:
this.$router.push({ path: '/datainputprogress' })
携带参数:
var ordercode = this.tbodyArr[index].ordercode ; var shopname = this.tbodyArr[index].shopname ; var branchname = this.tbodyArr[index].branchname ; this.$router.push({ path: '/datainputprogress', query: { ordercode: ordercode, shopname:shopname, branchname:branchname } }) ***跳转后获取参数:*** **方法一:** //获取地址栏信息 function getSearchString(key) { // 获取URL中?之后的字符 var addrstr = location.href; var str = addrstr.substring(addrstr.lastIndexOf("?") + 1, addrstr.length); //shopcode=125806649&branchcode=001&recommendid=6&openidfrom=&awardto=1001 // 以&分隔字符串,获得类似name=xiaoli这样的元素数组 var arr = str.split("&"); var obj = new Object(); // 将每一个数组元素以=分隔并赋给obj对象 for (var i = 0; i < arr.length; i++) { var tmp_arr = arr[i].split("="); obj[decodeURIComponent(tmp_arr[0])] = decodeURIComponent(tmp_arr[1]); } return obj[key] || ''; } 在created中: created(){ this.ordercode = api.getSearchString('ordercode'); } **方法二:** toMallInfo: function(mallCode){ this.$router.push({ path: '/propertyInfo/mall/mallList', // name: 'mallList', query: { mallCode: 'M000989' } }) }, created(){ this.getParams() }, methods :{ getParams(){ // 取到路由带过来的参数 const routerParams = this.$route.query.mallCode // 将数据放在当前组件的数据内 this.mallInfo.searchMap.mallCode = routerParams; this.keyupMallName() } }, watch: { '$route': 'getParams' }
相关文章推荐
- vue页面跳转携带参数
- vue页面跳转参数传递
- href携带参数跳转页面
- (vue)实现页面跳转 并且同时带上参数 进行传递
- 将参数放在URL中(点击列表中的某条记录携带信息进行页面跳转)
- 微信小程序开发之页面跳转并携带参数
- vue前端页面跳转参数传递及存储
- Vue中如何使用路由跳转页面及传递参数
- 页面跳转参数携带与参数接收的几种方式
- 页面跳转时参数携带与参数接收的几种方式
- vue通过 vue.mixin(混合)实现 任意页面记录滚动条位置(路由router.query参数一致) 并跳转到上次的位置
- vue使用路由进行页面跳转时传递参数
- thinkPHP传数组到模板页面volist每一列加一个button,点击按钮携带参数传给JS函数,跳转到不同的方法
- JavaScript带参数跳转页面
- jsp与servlet之间页面跳转及参数传递实例
- WP8页面跳转实现参数传递的多种方法
- 记录一个Spring MVC Controller层,跳转到前端页面以及返回参数的包装类
- Vue 爬坑之路(三)—— 使用 vue-router 跳转页面
- Vue页面跳转保留数据
- vue路由带参跳转,刷新后参数不消失