<router-link to="/home">home</router-link>
<router-link :to="{ name: 'user', params: { userId: '123' }}">user</router-link>
<router-link :to="{ path: '/user', query: { userId: '123' }}">user</router-link>
<!-- 加入replace不生成记录 -->
<router-link to="/abc" replace>abc</router-link>
router.push('/user/jia')
router.push(`add/${id}`)
router.push({ path: '/user/jia' })
// 通过params传参,不会显示在path上,页面刷新数据会丢失
router.push({ name: 'user', params: { username: 'jia' } })
route.params.username // 获取
// 通过query传参,会显示在path上,页面刷新数据不丢失
router.push({ path: '/register', query: { username: 'jia' } })
route.query // 获取
// replace类似
router.go()
标签:vue,jia,route,user,path,push,router,路由
From: https://www.cnblogs.com/jia-zq/p/16742909.html