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: "创新园二期"
  • 相关阅读:
    Django 【第十二篇】Form组件进阶
    Django 【第十一篇】Form组件基础
    前端知识点总结
    vue组件续和前端工程化
    vue组件
    Vue视图下
    Vue实例与渲染
    BootStrap
    jQuery事件与动画
    dom操作 属性操作 样式操作
  • 原文地址:https://www.cnblogs.com/Byme/p/14917609.html
Copyright © 2011-2022 走看看