Row 栅格行
uni-appH5微信小程序App
24 栅格布局行,支持间距、水平和垂直对齐。
何时使用
需要等分或按比例划分页面的多列布局。
何时不使用
简单的一维排列用 Stack 或 CSS 即可。
本文档为 uni-app 端组件契约;Web 端同名组件 API 可能略有差异,请以对应包文档为准。下方手机预览实时运行 uni-app H5 演示。
Props
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
gutter | number | 0 | 列间距(px),负 margin + 列内 padding 实现,列宽百分比不受影响 |
justify | string:'start' | 'center' | 'end' | 'between' | 'around' | "start" | 水平对齐方式 |
align | string:'top' | 'middle' | 'bottom' | "top" | 垂直对齐方式 |
Slots
| 名称 | 说明 |
|---|---|
default | Col 子项 |
示例
基础分栏
vue
<Row :gutter="8">
<Col :span="12"><view class="demo-box"><text>span 12</text></view></Col>
<Col :span="12"><view class="demo-box"><text>span 12</text></view></Col>
</Row>
<Row :gutter="8" style="margin-top:8px">
<Col :span="8"><view class="demo-box"><text>8</text></view></Col>
<Col :span="8"><view class="demo-box"><text>8</text></view></Col>
<Col :span="8"><view class="demo-box"><text>8</text></view></Col>
</Row>对齐方式
vue
<Row justify="between" align="middle">
<Col :span="6"><view class="demo-box"><text>左</text></view></Col>
<Col :span="6"><view class="demo-box"><text>右</text></view></Col>
</Row>
<Row justify="center" style="margin-top:8px">
<Col :span="6"><view class="demo-box"><text>居中</text></view></Col>
</Row>
<Row justify="end" style="margin-top:8px">
<Col :span="6"><view class="demo-box"><text>靠右</text></view></Col>
</Row>垂直居中
vue
<Row align="middle" :gutter="8">
<Col :span="8"><view class="demo-box" style="height:64px"><text>高</text></view></Col>
<Col :span="8"><view class="demo-box"><text>低</text></view></Col>
</Row>