vue 路由监听

 

监听路由 和 同页面跳转只有传递参数发生变化的问题

解决方法:

watch:{

  '$route' (tofrom) {

  console.log('to',to)

     console.log('from',from)

  },

}

路由跳转 

方法一:

路由跳转+传参

this.$router.push({

  path: "/HomeResult",

  query: {

    indexId:'001'

  }

});

获取形式

  let indexId = this.$route.query.indexId;

方法二:

路由设置:

path: '/Help/:indexId',

路由跳转+传参

  this.$router.push("/Help/001");

获取形式

  let indexId this.$route.params.indexId;

 

方法三(使用路由打开新页面)

路由跳转+传参

  let routeUrl = this.$router.resolve({

              path: "/Help",

              query: {

                indexId:'001'

              }

        });

      window.open(routeUrl.href, '_blank');

获取形式

    let indexId = this.$route.query.indexId;