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: "创新园二期"
  • 相关阅读:
    SQL SERVER 2005分区表切换
    对SQL SERVER2005中表和索引存储结构的一些理解
    SQL SERVER 2005 DBCC IND命令说明
    面向对象的基本原则
    SQL SERVER 2005 DBCC PAGE命令说明
    Mac 使用ab性能测试工具
    Struts2初始化过程代码分析
    maven开发过程实践之二(配置项与源代码分离 processresources)
    简单之美
    Maven开发过程实践之三—(单元测试报告 test)
  • 原文地址:https://www.cnblogs.com/Byme/p/14917609.html
Copyright © 2011-2022 走看看