1.router-link跳转

<!-- 直接跳转 -->
<router-link to='/testDemo'>
 <button>点击跳转2</button>
</router-link>
  
<!-- 带参数跳转 -->
<router-link :to="{path:'testDemo',query:{setid:123456}}">
 <button>点击跳转1</button>
</router-link>
  
<router-link :to="{name:'testDemo',params:{setid:1111222}}">
 <button>点击跳转3</button>
</router-link>

2:this.$router.push()

//直接跳转
 this.$router.push('/a');
  
 //带参数跳转
 this.$router.push({path:'/a',query:{a:123456}});
 this.$router.push({name:'a',params:{a:123456}});

3.获取参数

console.log(this.$route.query.a);
console.log(this.$route.params.a);
Logo

前往低代码交流专区

更多推荐