vue路由跳转写法在html,vue路由跳转的多种方式

1.router-link to 跳转

跳转

2.this.$router.push("ComponentName") ,通过路由名称跳转

跳转

go(){this.$router.push("Child");

},

3.this.$router.push({path:"/child"}) ,通过路由的path跳转

跳转

go2(){this.$router.push({path:"/child"});

},

4.带参数跳转 this.$router.push({path:"/child",params:{test:123}})

带参数跳转

go3(){this.$router.push({path:"/child?test=123"})

},

这种跳转的路由地址和参数是这样的,用问号拼接的,

20190118191309970114.png

获取路由参数,this.$route.query.paramsName

获取路由参数

getParams(){

console.log(this.$route.query.test); //123

}

5.跳转到上一个路由,this.$router.go(-1)

返回上一页

goback(){this.$router.go(-1);

}

6.命名路由的跳转,需要在配置路由上带上参数,

{

name:"Children",

path:"/children/:test",

component:Children

}

跳转带参数

这种跳转的路由地址和参数是这样的,用 / 拼接的,

20190118191310080459.png

获取路由参数:this.$route.params.xxx

获取路由参数

getParams(){

console.log(this.$route.params.test);

}

原文:https://www.cnblogs.com/luguankun/p/10289038.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值