树样式优化。

This commit is contained in:
tengge1 2019-05-14 20:29:04 +08:00
parent 8d3bd81c99
commit 2c50668b4a
2 changed files with 20 additions and 4 deletions

View File

@ -23,18 +23,18 @@ class Tree extends React.Component {
list.push(this.createNode(n));
});
return <ul>{list}</ul>;
return <ul className={classNames('Tree', className)} style={style}>{list}</ul>;
}
createNode(data) {
const leaf = !data.children || data.children.length === 0;
const children = leaf ? null : (<ul>{data.children.map(n => {
const children = leaf ? null : (<ul className={'sub'}>{data.children.map(n => {
return this.createNode(n);
})}</ul>);
return <li value={data.value} key={data.value}>
return <li className={'node'} value={data.value} key={data.value}>
<a href={'javascript:;'}>{data.text}</a>
{leaf ? null : <ul>{children}</ul>}
{leaf ? null : children}
</li>;
}
}

View File

@ -0,0 +1,16 @@
.Tree {
list-style: none;
margin: 0;
padding: 0;
}
.Tree .node a {
color: #555;
text-decoration: none;
}
.Tree .node .sub {
list-style: none;
margin: 0;
padding: 0 0 0 16px;
}