render() { const rows = array_chunk(this.props.columns, 4) return ( { rows.map((row) => ( <div className="row"> {row.map((col) => ( <div className="col">{ col }</div>)) } </div> )) } )}一个array_chunk示例(我建议您使用lodash)
module.exports = function chunks(arr, size) { if (!Array.isArray(arr)) { throw new TypeError('Input should be Array'); } if (typeof size !== 'number') { throw new TypeError('Size should be a Number'); } var result = []; for (var i = 0; i < arr.length; i += size) { result.push(arr.slice(i, size + i)); } return result;};


