• typescript for exception


    ...

    for 循环之前需要初始化被赋值的对象,否则每次被赋值的是同一个对象,而且是这个对象最后一次被赋值的情况

    参考 https://blog.csdn.net/qq_38758765/article/details/115749097

    HuDerr(): void{
        this.data3.data.sections.forEach(
          (value, index, array) =>{
            console.log('L1', value);
            let va = array[index];
            this.IIdd.title = va.name;
            this.IIdd.id = va.sectionId;
            va.items.forEach(
              (value2, index1, array1) => {
                console.log('L2 for ====>', value2, 'index1==>' ,index1, 'arr1==>', array1);
                let vaa = array1[index1];
                this.Idd.title = vaa.name;
                this.Idd.id = vaa.id;
              }
            );
            this.IIdd.children.push(this.Idd);
            console.log('L1===>', this.IIdd);
            console.log('l1 sep===>');
            this.data1.push(this.IIdd);
            // console.log('in for data1===>', this.data1);
            return;
          }
        );
      }
    
      HuD(): void {
    
        for (const item of this.data3.data.sections) {
          this.IIdd = {
            id: '',
            title: '',
            children: []
          };
          this.IIdd.title = item.name;
          this.IIdd.id = item.sectionId;
          console.log(this.IIdd);
          const va = item;
          for (let emm of va.items){
            this.Idd = {id: '', title: '' };
            const mm =emm;
            console.log('emm===>', mm);
            this.Idd.id=mm.id;
            this.Idd.title=mm.name;
            this.IIdd.children.push(this.Idd);
            console.log(this.IIdd);
            continue;
          }
          this.data1.push(this.IIdd);
          console.log(this.data1);
          console.log('L1 spw');
        }
      }
    

      

  • 相关阅读:
    分治思想
    二分查找---查找区间
    二分查找---有序数组的 Single Element
    Ogre碰撞检测
    JavaScript常用检测脚本(正则表达式)
    Js+XML 操作
    C++难点的一些总结
    MFC使用简单总结(便于以后查阅)
    vc中调用Com组件的所有方法详解
    OSG+VS2010+win7环境搭建---OsgEarth编译
  • 原文地址:https://www.cnblogs.com/eiguleo/p/14797818.html
Copyright © 2020-2023  润新知