vue 路由跳转的方式总结

2021-02-01  本文已影响0人  一只章鱼哥

1.路由标签跳转

<router-link :to="{path, params, query}"></router-link>

path表示跳转的路径

name表示跳转路由名称

2.函数操作(params方式传参)

// 对象写法
this.$router.push({
  name: 'router name',
  params: {
    key: value
      ...
    }
})
// 字符串写法
this.$router.push('/index/page1)

3.函数操作(query方式传参)

// 对象写法
this.$router.push({
  name: 'router name',
  query: {
    key: value
      ...
    }
})
// 字符串写法
this.$router.push('/index/page1?param1=param1&param2=param2')
上一篇 下一篇

猜你喜欢

热点阅读