zoukankan      html  css  js  c++  java
  • js 修改属性名和值。并只保留需要的属性

    
    
    result.data =
     [
                {
                  id: "0c4a850086f211eb88ce2e17e48e1195",
                  name: "创新园二期",
                  parentId: "0",
                  iconSkin: "group",
                  isParent: true,
                  orgNode: true,
                  limit: false,
                  polygon: null,
                  lng: null,
                  lat: null,
                  mapImage: null,
                  mobile: null,
                  userId: null,
                  type: 0,
                  code: null,
                  username: null,
                  chief: null,
                  checked: false,
                  nodes: null,
                },
                {
                  id: "0c4a850086f211eb88ce2e17e48e11951111",
                  name: "创新园二期11111",
                  parentId: "0",
                  iconSkin: "group",
                  isParent: true,
                  orgNode: true,
                  limit: false,
                  polygon: null,
                  lng: null,
                  lat: null,
                  mapImage: null,
                  mobile: null,
                  userId: null,
                  type: 0,
                  code: null,
                  username: null,
                  chief: null,
                  checked: false,
                  nodes: null,
                },
              ];


    this
    .treedata = result.data; if (this.treedata && this.treedata.length != 0) {
           

           //删除其他不需要的属性
    this.treedata = this.treedata.map((item, index) => {
              item["title"] = item.name;
    return Object.assign(
                    {},
                    { title: item.title },
                    { loading: false },
                    { children: [] },
                    {
                      id: item.id,
                    }
                  );
                });
              }
              console.log(222, this.treedata);
    得到的结果。
    1. children: Array(0)
    2. id: "0c4a850086f211eb88ce2e17e48e1195"
    3. loading: false
    4. nodeKey: 0
    5. title: "创新园二期"
  • 相关阅读:
    计算机网络-数据结构-MAC帧头-IP头-TCP头-UDP头
    (考研)java网络编程
    多态(重点:方法的多态性和对象的多态性)
    JZOJ1497 景点中心 题解
    JZOJ1227 Coprime 题解
    JZOJ3966 Sabotage 题解
    JZOJ3056 数字 题解
    JZOJ3054 祖孙询问 题解
    【Luogu P2282】【JZOJ 4906】【NOIP2016提高组复赛】组合数问题 题解
    JZOJ4316【NOIP2015模拟11.5】Isfind 题解
  • 原文地址:https://www.cnblogs.com/Byme/p/14917609.html
Copyright © 2011-2022 走看看