zoukankan      html  css  js  c++  java
  • react ice tree报错type

    线上的tree报了错,connot read ptoperty 'type' of undefined

    后面发现 这里有问题,没有判断条件不满足时返回为空,所以会自己返回undefined,导致报错

    const loop = (data) => data.map(item => {
            if (item.branchType == 1 || item.branchType == 2 || item.branchType == 3) {
              return <TreeNode
                label={<Fragment>{Icon(item.branchType)}{item.branchSimpleName}</Fragment>}
                key={item.id}
                data={item}
                >
                {item.children && item.children.length > 0 ? loop(item.children) : null}
                </TreeNode>
            } else {
          // 此处加一个返回为空的判断
    return '' } })
    { data && data.length > 0 ? <React.Fragment>
                <Tree
                  defaultExpandAll={false}
                  autoExpandParent={autoExpandParent}
                  draggable={true}
                  defaultExpandedKeys={defaultExpandedKeys}
                  filterTreeNode={filterTreeNode}
                  expandedKeys={expandedKeys}
                  onExpand={this.handleExpand}
                  onSelect={this.treeNodeonRightClick}
                  animation={true}
                  selectedKeys={selectedKeys}
                  showLine
                  >
                  {loop([...data])}
                </Tree>
              </React.Fragment> : ''}
  • 相关阅读:
    英语俚语里的gotta和gonna
    如何设置Win XP远程登录如何远程控制电脑
    C#中as与is的用法(收藏)
    just用法
    even用法
    up to用法小结
    go out with用法
    realize与recognize辨析
    go through用法
    堆优先队列
  • 原文地址:https://www.cnblogs.com/zhuangcui/p/12937816.html
Copyright © 2011-2022 走看看