ant-design树选择框生成treeData数据结构
发布日期:2021-05-20 10:06:56 浏览次数:26 分类:技术文章

本文共 1174 字,大约阅读时间需要 3 分钟。

1、使用TreeSelect组件时,我们需要根据接口返回的数据生成官方样例的数组结构

加粗样式

2、因为比较基础简单,希望帮到更多的初学者,这里主要是分享代码,代码有根据具体情况命名进行修改,仅供参考

const classGradesData = [];    // eslint-disable-next-line no-unused-expressions    classTypeSet &&      classTypeSet.forEach((item, idex) => {
// 生成children数组结构 const gradesChildren = []; gradeList.forEach((itm, idx) => {
if (item === itm.classType) {
gradesChildren.push({
grade: itm.gradeName, value: itm.gradeEnum, key: idx }); } }); // 生成value label数组结构 const newGradesData = {
label: item, key: idex, gradesChildren, }; return classGradesData.push(newGradesData); });

在这里插入图片描述

  • 使用

在这里插入图片描述

转载地址:https://blog.csdn.net/weixin_45416217/article/details/110098650 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:解决ant-design表格固行和列多出空白列的问题
下一篇:reduce方法实现对数组相邻相同元素进行合并

发表评论

最新留言

很好
[***.229.124.182]2024年04月19日 00时03分44秒