<router-link :to="{ name:'router1',params: { id: status}}" >正确</router-link>
<router-link :to="{ name:'router1',params: { id2: status}}">错误</router-link> //这种也可以
this.$router.push({ path:"/discover", //可选 name:"discover", params: { id: 5555}, query: { queryId: 66666 } // })
条件:路由配置中必须有name参数;
{ path: '/discover', name: 'discover', component: discover },
弊端:
刷新页面 params 参数会丢失;
根据网上大神的建议,再路由配置中加了path: '/describe/:id', 相当于混合了第一种方式; 但是。。。。。。。。
query不会;
mounted(){ var pars = this.$route.params; var quer = this.$route.query; console.log(pars) //{id: 5555} console.log(quer) //{queryId: 66666} }