路由的跳转传值:
在路由设置 path: '/xx/:id', 接收数据this.$route.params 例如 this.$route.params.id
// 命名的路由
this.router.push({ name: 'user', params: { userId: '123' }})
在目标页面通过this.$route.query获取参数:
this.$route.query.row.xxx
监控路由
watch: { $route(to,from){ console.log('路由变化 !'+to.path) if(to.path=='/account/sc'){ this.getwish() } } }
子组件给父组件传值
prps
<cp :cid="cid"> cp 为子组件 可以监测 可以在在cp的那个页面监测 watch: { cid(val) { } }
父组件给子组件传值
点击事件
子组件里面里面有个方法
lbcp(id){
this.$emit('cplb',id)
}
父组件里面的方法
<left @cplb="acc">