直接上代码
<el-cascader
:options="options"
v-model="selectedOptions"
@change="handleChange">
</el-cascader>
element-ui所要求的数据格式:
options: [{
value: 'zhinan',
label: '指南',
children: [{
value: 'shejiyuanze',
label: '设计原则',
children: [{
value: 'yizhi',
label: '一致'
}]
}]
}]
而后端给的是以下格式,并且带了空 children
options: [{
id: 'zhinan',
value: '指南',
children: [{
id: 'shejiyuanze',
value: '设计原则',
children: [{
id: 'yizhi',
value: '一致',
children:[]
}]
}]
}]
解决方法:
在 handleChange 中能获取到所选择到的