fix(tree中只有一个子节点时不显示): 支持只有一个子节点

只有一个自己点时也可以正常显示
This commit is contained in:
wanghaoo 2018-02-28 16:51:03 +08:00
parent 2de131a7a1
commit ac619e194c
2 changed files with 8 additions and 4 deletions

View File

@ -255,10 +255,14 @@ var TreeNode = function (_React$Component) {
}
var children = props.children;
var newChildren = children;
var allTreeNode = undefined;
if (Array.isArray(children)) {
allTreeNode = children.every(function (item) {
return item.type === TreeNode;
});
}
//如果props.children的长度大于0才可以生成子对象
if (children && children.length > 0 && (children.type === TreeNode || Array.isArray(children) && children.every(function (item) {
return item.type === TreeNode;
}))) {
if (children && (children.type === TreeNode || allTreeNode)) {
var _cls;
var cls = (_cls = {}, _defineProperty(_cls, props.prefixCls + '-child-tree', true), _defineProperty(_cls, props.prefixCls + '-child-tree-open', props.expanded), _cls);

View File

@ -1,6 +1,6 @@
{
"name": "bee-tree",
"version": "1.0.9",
"version": "1.1.0",
"description": "Tree ui component for react",
"keywords": [
"react",