您的位置:首页 > Web前端 > Vue.js

vue带有参数的路由跳转

2018-06-01 10:16 260 查看
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_27848369/article/details/80534156
  vue带有参数的路由跳转: 
   1. 接收路由传递的参数有两种方式; (this.$router.history.current.params 、 this.$route.params)
   2. 为避免在跳转页面F5数据丢失,需要将传递的参数存到sessionStorage
   3. 跳转的地方,路由跳转时, 不可使用 path, 要使用name。 (path适用于不带参数的跳转)
   
  created(){
 
      let info = this.$router.history.current.params.info;
  //  let info = this.$route.params.info;
      if (info) {
        sessionStorage.setItem("detailItem12", info);
      }
      let houseId = sessionStorage.getItem("detailItem12") + '';
      this.houseId = houseId;
    },


  gotoDetailPage: function (index, rowData) {
          let routerName = '';
        if (rowData.houseLivedState == 1) {
          routerName = 'HouseDetail1';
        }else if(rowData.houseLivedState == 2){
          routerName = 'HouseDetail2';
        }else if(rowData.houseLivedState == 3){
          routerName = 'HouseDetail3';
        }else{


        }
        this.$router.push({
            name : routerName,
            params: {
                'info': rowData.id
            }
        })
      }, 阅读更多
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: