let cityList = [
{id: 1, parentId: 0,name: '江苏省'},
{id: 2,parentId: 0,name: '广东省'},
{id: 3,parentId: 0,name: '湖南省'},
{id: 4,parentId: 1,name: '苏州市'},
{id: 5,parentId: 1,name: '无锡市'},
{id: 6,parentId: 1,name: '南通市'},
{id: 7,parentId: 2,name: '广州市'},
{id: 8,parentId: 2,name: '深圳市'},
{id: 9,parentId: 3,name: '长沙市'},
{id: 10,parentId: 4,name: '工业园区'},
{id: 11,parentId: 4,name: '吴中区'},
{id: 12,parentId: 4,name: '姑苏区'}
];
listToTree();
function listToTree() {
console.log(111111111)
let array = [];
cityList .forEach(item =&g
将数据使用js实现树形结构
最新推荐文章于 2024-08-22 17:38:39 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)