本文共 1163 字,大约阅读时间需要 3 分钟。
配置:(传参):to="{name:'login', query:{id:'loginid'}}"
获取:(取参)this.$route.query.id配置:(传参):to="{name:'login', params:{id:'loginid'}}"
获取:(取参)this.$route.params.id配置:(传参):to="{name:'register', params:{id:'registerid'}}"
配置路由规则:routes: [{path: '/register/:id/info', name: 'register', component: Register}]获取:(取参)this.$route.params.id配置:(传参):to="{name:'propsParams', params:{id:'propsParamsId'}}"
配置路由规则:routes: [// 通过props传值{path: '/propsParams', name: 'propsParams', props: true, component: PropsParams}]获取:(取参)var PropsParams = { template: `传参直接取值 直接拿到ID:{ {id}}`, // 直接通过props取参 props: ['id'] }
this.$router.push({path: '/login', name: 'login', query: {id: 'loginidjs'}})
query传参:
Title
params传参
Title
params路径传参
Title
params使用props直接取参
Title
js传参
Title
fullPath路由全路径监听
Title
完整代码示例:
Title
转载于:https://blog.51cto.com/12012821/2407154