给 cascader
组件赋值一个别名
<el-form-item label="部门" prop="departmentId"> <el-cascader ref="cascaderAddr" :options="departmentData" change-on-select v-model="departmentIds" :props="defaultProps" @change="getDepartmentId" clearable > </el-cascader> </el-form-item>
然后我们就可以通过 currentLabels
来获取 cascader
组件中的 label
了
// 选择部门
getDepartmentId(currentVal) {
if (currentVal.length == 0) {
this.conditionForm.departmentId = '';
} else {
console.log(currentVal,this.departmentIds);
// this.departmentId = currentVal[currentVal.length-1];
this.conditionForm.departmentId = currentVal.join(',');
this.conditionForm.departmentName = this.$refs['cascaderAddr'].currentLabels.join(',');
}
},