JS数组遍历-forEach()、map()方法

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_33242126/article/details/83178746
[{a:'1',b:'11'},{a:'2',b:'21'},{a:'3',b:'31'}].forEach((item, index, array) => {
  let c = '';
  let d = '21';
  c = d == item.b ? item : '';
  console.log(c)
})

 

// 列表页展示
  searchRulesByPage(pageModel: PageModel, searchObj: MchtRuleSearchObj) {
    const _searchObj = ObjectUtils.removeEmptyAttr(searchObj);
    return this.networkService.post({urlStr: '/mchrules/list', body: {...pageModel, ..._searchObj}}).map(res => {
      // 格式化数据 1=> true 0 =》false
      if (res.code === '200') {
        res.data.list.map((val, index, array) => {
          val.status = val.status === '1' ? true : false;
          return val;
        });
      }
      console.dir(res);
      return res;
    });
  }
 // 批量修改商户规则
  batchEditMchRules(dialogObj, mchs: any[]) {
    // 批量修改
    mchs.forEach((value, index, array) => {
      for (const prop in dialogObj) {
        if (dialogObj.hasOwnProperty(prop) === true) {
          value[prop] = dialogObj[prop];
        }
      }
    });
    // 格式化状态字段
    mchs.forEach((value, index, array) => {
      value.status = value.status ? '1' : '0';
    });
    return this.networkService.post({urlStr: '/mchrules/update', body: mchs}).map(res => {
      return res;
    });
  }
 MAINDATASERVICE.get_dossBasicData().then(res => {
          this.options = res['leadsFeedbackReasons'].map((val, index, arr) => {
            return val = Object.assign({},val,{isActive: false});
          });
          console.log('this.options',this.options)
        })

猜你喜欢

转载自blog.csdn.net/qq_33242126/article/details/83178746
今日推荐