后端返回的树结构数据:
template:
<el-cascader v-model="ruleForm.columnAll" :options="allColumnData" :props="{ value: 'columnId', label: 'columnName', children: 'children' }" />methods:
// 获取栏目树列表集合 getColumnTrees() { this.ruleForm.columnId = parseInt(this.$route.query.columnId); this.allColumnData = []; getColumnTree().then(res => { this.allColumnData = this.getTreeData(res.data); }).catch(_ => { }) }, getTreeData(data) { // 循环遍历json数据 for (var i = 0; i < data.length; i++) { if (data[i].children.length == 0) { data[i].children = undefined; } } return data; },
标签:控件,columnId,el,element,cascader,data,children From: https://www.cnblogs.com/moguzi12345/p/17756683.html