数据处理,递归直到末端,如果children: null,就在上一个children的同级加一个 disable: true

没处理之前的数据
listTerms: [
{
id: '11',
path: 1.1,
name: '81',
children: [
{
id: '22',
path: 1.1,
name: '82',
children: [
{
id: '55',
path: '1.1.1',
name: '83',
children: null
},
{
id: '66',
path: '1.1.2',
name: '84',
children: null
}
]
},

    }
  ],

处理之后的数据

listTerms: [
{
id: '11',
path: 1.1,
name: '81',
children: [
{
id: '22',
path: 1.1,
name: '82',
disable: true,
children: [
{
id: '55',
path: '1.1.1',
name: '83',
children: null
},
{
id: '66',
path: '1.1.2',
name: '84',
children: null
}
]
},

    }
  ],
const deepFn = (list, str) => {
    list.forEach(item=>{
      const findStrObj = item[str].find(sonItem=>Object.prototype.toString.call(sonItem[str]) === '[object Null]');
      if(findStrObj){
        item.display = true;
      }else{
        deepFn(item[str], str)
      }
    })
    return list;
  }
  console.log(deepFn(listTerms, 'children'))