调整渲染方式

This commit is contained in:
2betop 2020-07-28 17:08:14 +08:00
parent aa3cd30653
commit f0328ea6ac
2 changed files with 29 additions and 23 deletions

View File

@ -103,27 +103,32 @@ export default class Grid<T> extends React.Component<GridProps & T, object> {
fromBsClass((column as Column).columnClassName)
)}
>
{Array.isArray(column)
? this.renderColumns(column)
: this.renderChild(`column/${key}`, column, key, length)}
</div>
);
}
renderColumns(columns: ColumnArray): React.ReactElement<any> | null {
const {className, classnames: cx} = this.props;
return (
<div className={cx('Grid', className)}>
{columns.map((column, key) =>
this.renderColumn(column, key, columns.length)
{Array.isArray(column) ? (
<div className={cx('Grid')}>
{column.map((column, key) =>
this.renderColumn(column, key, column.length)
)}
</div>
) : (
this.renderChild(`column/${key}`, column, key, length)
)}
</div>
);
}
renderColumns(columns: ColumnArray) {
return columns.map((column, key) =>
this.renderColumn(column, key, columns.length)
);
}
render() {
return this.renderColumns(this.props.columns);
const {className, classnames: cx} = this.props;
return (
<div className={cx('Grid', className)}>
{this.renderColumns(this.props.columns)}
</div>
);
}
}

View File

@ -56,17 +56,18 @@ export default class HBox extends React.Component<HBoxProps, object> {
);
}
render() {
const {className, columns, classPrefix: ns} = this.props;
renderColumns() {
const {columns} = this.props;
return (
<div className={cx(`${ns}Hbox`, className)}>
{columns.map((column, key) =>
this.renderColumn(column, key, columns.length)
)}
</div>
return columns.map((column, key) =>
this.renderColumn(column, key, columns.length)
);
}
render() {
const {className, classnames: cx} = this.props;
return <div className={cx(`Hbox`, className)}>{this.renderColumns()}</div>;
}
}
@Renderer({