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: "创新园二期"
  • 相关阅读:
    小编见过的验证方式汇总
    Burp Suite Professional 针对APP抓包篡改数据提交【安全】
    关于Chrome 67 以后版本无法离线安装扩展的解决方法
    Postman 中上传图片的接口怎么做参数化呢?
    字符串-不同的编码格式下所占用的字节数【转】
    Java RandomAccessFile用法 【转】
    URI和URL的区别 【转】
    Java多线程-线程的同步与锁【转】
    浅谈Java多线程的同步问题 【转】
    Java中浮点数的精度问题 【转】
  • 原文地址:https://www.cnblogs.com/Byme/p/14917609.html
Copyright © 2011-2022 走看看