1.父组件传子组件
父组件定义一个值,在子组件引入下面直接绑定
<Batchdistribution
:batchdistribution="batchdistribution" 控制窗口显示
:selections="selections" 全选的数据给子组件
:deptuseroption='deptuseroption' 部门用户的数据赋值给子组件
></Batchdistribution>
子组件接收:通过props来接收父组件传过来的值
props: {
batchdistribution: Boolean,
selections: Array,
deptuseroption:Array
}
子组件直接绑定值
<el-option
v-for="item in deptuseroption"
:key="item"
:label="item.userName"
:value="item.id"
></el-option>
2.子组件给父组件传值:通过提交方法来传值 this.$emit
// 点击部门
handleTreeSelectChange3Add(data, node) {
this.$emit("handleTreeSelectChange3Add",{data:data,node:node})
},
ColsePop: function(val) {
this.$emit("ColsePop");
},
父组件接收:
<Batchdistribution
@ColsePop="ColsePop"
@batchdistributionsubmitdept='batchdistributionsubmitdept'
@handleTreeSelectChange3Add="handleTreeSelectChange3Add "
></Batchdistribution>
通过方法来接收传过来的值
ColsePop: function() {
this.batchdistribution = false;
},
// 点击部门
handleTreeSelectChange3Add(params) {
this.deptinputValue = params.data.deptName;
this.deptId = params.data.id;
},