父组件获取子组件的数据和方法
one
在父组件中调用子组件时,定义一个ref(其实和选择器类似):
<Common ref="commonChild" :pathologyId="form.pathologyId" />
在父组件中获取子组件属性和方法写法:
this.$refs.commonChild.属性
this.$refs.commonChild.方法
two
Vue官网上有这个实例属性,但使用需要自定义组件顺序
子组件获取父组件的数据和方法
在子组件中获取父组件属性和方法写法:
this.$parent.属性
this.$parent.方法
参考来源于:
https://cn.vuejs.org/v2/api/#vm-children
https://blog.youkuaiyun.com/zhongshijun521/article/details/80610971