--- order: 10 title: zh-CN: 栅格配置器 en-US: Playground --- ## zh-CN 可以简单配置几种等分栅格和间距。 ## en-US A simple playground for column count and gutter. ```jsx import { Row, Col, Slider } from 'antd'; const gutters = {}; const vgutters = {}; const colCounts = {}; [8, 16, 24, 32, 40, 48].forEach((value, i) => { gutters[i] = value; }); [8, 16, 24, 32, 40, 48].forEach((value, i) => { vgutters[i] = value; }); [2, 3, 4, 6, 8, 12].forEach((value, i) => { colCounts[i] = value; }); export default () => { const [state, setState] = React.useState({ gutterKey: 1, vgutterKey: 1, colCountKey: 2, }); const onGutterChange = gutterKey => { setState({ ...state, gutterKey }); }; const onVGutterChange = vgutterKey => { setState({ ...state, vgutterKey }); }; const onColCountChange = colCountKey => { setState({ ...state, colCountKey }); }; const { gutterKey, vgutterKey, colCountKey } = state; const cols = []; const colCount = colCounts[colCountKey]; let colCode = ''; for (let i = 0; i < colCount; i++) { cols.push(
{`\n${colCode}\n${colCode}
`}
{`> ); }; ``` ```css #components-grid-demo-playground [class~='ant-col'] { background: transparent; border: 0; } #components-grid-demo-playground [class~='ant-col'] > div { height: 120px; font-size: 14px; line-height: 120px; background: #0092ff; border-radius: 4px; } #components-grid-demo-playground pre { padding: 8px 16px; font-size: 13px; background: #f9f9f9; border-radius: 6px; } #components-grid-demo-playground pre.demo-code { direction: ltr; } #components-grid-demo-playground .ant-col { padding: 0; } ```\n${colCode}
`}