update 细节处理

This commit is contained in:
2021-06-28 21:35:07 +08:00
parent e8dd6f4eca
commit 19cb1984b0
3 changed files with 57 additions and 29 deletions

View File

@@ -5,24 +5,41 @@ function renderActions() {
const { children } = this.props
const actions = []
Array.isArray(children) ? children
.filter(action => action)
.forEach((action, i) => {
actions.push(action)
if (i < this.props.children.length - 1) {
actions.push(<Divider type="vertical" key={i} />)
}
}) : (actions.push(children))
Array.isArray(children)
? children
.filter(action => action)
.forEach((action, i) => {
actions.push(action, <Divider type="vertical" key={i} />)
})
: actions.push(children)
return actions
}
export default class QueryTableActions extends Component {
componentDidMount() {
// 删除多余的间隔线
const className = 'ant-divider ant-divider-vertical'
let series = false
for (const node of this.refs.inner.childNodes) {
if (
(series && node.className == className) ||
(!node.nextElementSibling && node.className == className)
) {
node.remove()
series = false
} else if (node.className == className) {
series = true
} else {
series = false
}
}
}
render() {
return (
<div className="yo-table-actions">
<div className="yo-table-actions--inner">
<div className="yo-table-actions--inner" ref="inner">
{renderActions.call(this)}
</div>
</div>