美文网首页react + dva + antdantd
antd tree 默认展开第几层

antd tree 默认展开第几层

作者: _请输入昵称 | 来源:发表于2019-01-28 12:01 被阅读1次

    操作autoExpandParent和expandCode

    state = {
      autoExpandParent: true,
    }
    
    // 展开缩起触发
      expand (key,label) {
        this.setState({
          autoExpandParent: false,
        })
        // 保存受控的expandCode
        this.props.dispatch({
          type: '***save',
          payload: {
            expandCode: key
          } 
        })
      }
    
    renderTreeNodes() {
      // render treenodes
    }
    
    // render
    render() {
      return (
        <div>
          {
             treeData && treeData.length > 0 ?
                <Tree
                   autoExpandParent={autoExpandParent}
                   expandedKeys={expandCode}
                   onExpand={(key,label)=>{this.expand(key,label)}}
                  >
                    {this.renderTreeNodes(newTreeData)}
                </Tree> : ''
             }
        </div>
      )
    }
    
    
    

    相关文章

      网友评论

        本文标题:antd tree 默认展开第几层

        本文链接:https://www.haomeiwen.com/subject/xkqajqtx.html