溫馨提示×

vue中路由跳轉的方式有哪些

養魚的貓咪
393
2021-03-29 14:44:17
欄目: 編程語言

vue中實現路由跳轉的方式有:1.通過router-link標簽跳轉;2.通過this.$router.push()事件跳轉;3.通過this.$router.go(n)事件跳轉;

vue中路由跳轉的方式有哪些

vue中實現路由跳轉的方式有以下幾種

1.通過router-link標簽跳轉

// 配置路由

path: '/user/:id'

<router-link :to="'/user/' + this.id"> <router-link/>

// 接收參數

this.$route.params.id

2.通過this.$router.push()事件跳轉

1)跳轉字符串

this.$router.push('/home')

2)跳轉對象

this.$router.push({path:'/home'})

3.通過this.$router.go(n)事件跳轉

this.$router.go(1)

// 后退一步記錄

this.$router.go(-1)

// 前進三步記錄

this.$router.go(3)


0
亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女