zoukankan      html  css  js  c++  java
  • 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');
        }
      }
    

      

  • 相关阅读:
    第一章复习(已完结)
    复习——第二章(施工完成,哪里总结的不全或是有问题欢迎指出)
    实验九
    实验五
    实验四
    实验三
    实验二
    实验一
    汇编语言第二章
    【C# 大写金额转阿拉伯数字】大写金额转数值
  • 原文地址:https://www.cnblogs.com/eiguleo/p/14797818.html
Copyright © 2011-2022 走看看