路由跳转
一、 不带参数,name,path都行
//1、html
<router-link :to="{name:'home'}">
<router-link :to="{path:'/home'}">
//2、或js
this.$router.push('/home')
this.$router.push({name:'home'})
this.$router.push({path:'/home'})
二、params传参,跳转之后页面 url后面不会拼接参数
路由配置 path: “/home/:id” ,只能用 name
//1、 html
<router-link :to="{name:'home', params: {id:1}}">
//2、或js
this.$router.push({name:'home',params: {id:'1'}})
//获取
this.$route.params.key
三、query传参,参数相当于从连接里带过去
配置路由path: “/home/:id” 后不可用path,不配置路由可用path
//1、html
<router-link :to="{name:'home', query: {id:1}}">
//2、或js
this.$router.push({name:'home',query: {id:'1'}})
//获取
this.$route.query.key