Layout 布局
基于 Flex 栅格化系统,利用 Row 和列 Col 来定义信息区块的外部框架,以保证页面的每个区域能够稳健地排布起来。
vue
<template>
<ta-group title="基础用法">
<ta-row class="exp-layout-row">
<ta-col class="exp-layout-col">col-24</ta-col>
</ta-row>
<ta-row class="exp-layout-row">
<ta-col class="exp-layout-col" :span="12">col-12</ta-col>
<ta-col class="exp-layout-col" :span="12">col-12</ta-col>
</ta-row>
<ta-row class="exp-layout-row">
<ta-col class="exp-layout-col" :span="8">col-8</ta-col>
<ta-col class="exp-layout-col" :span="8">col-8</ta-col>
<ta-col class="exp-layout-col" :span="8">col-8</ta-col>
</ta-row>
<ta-row class="exp-layout-row">
<ta-col class="exp-layout-col" :span="6">col-6</ta-col>
<ta-col class="exp-layout-col" :span="6">col-6</ta-col>
<ta-col class="exp-layout-col" :span="6">col-6</ta-col>
<ta-col class="exp-layout-col" :span="6">col-6</ta-col>
</ta-row>
</ta-group>
<ta-group title="区块间隔">
<ta-row class="exp-layout-row" :gutter="10">
<ta-col class="exp-layout-col" :span="8">col-8</ta-col>
<ta-col class="exp-layout-col" :span="8">col-8</ta-col>
<ta-col class="exp-layout-col" :span="8">col-8</ta-col>
</ta-row>
</ta-group>
<ta-group title="左右偏移">
<ta-row class="exp-layout-row">
<ta-col class="exp-layout-col" :span="8">col-8</ta-col>
<ta-col class="exp-layout-col" :span="8" :offset="8">col-8 offset-8</ta-col>
</ta-row>
<ta-row class="exp-layout-row">
<ta-col class="exp-layout-col" :span="6" :offset="6">col-6 offset-6</ta-col>
<ta-col class="exp-layout-col" :span="6" :offset="6">col-6 offset-6</ta-col>
</ta-row>
<ta-row class="exp-layout-row">
<ta-col class="exp-layout-col" :span="12" :offset="6">col-12 offset-6</ta-col>
</ta-row>
</ta-group>
<ta-group title="栅格排序">
<ta-row class="exp-layout-row">
<ta-col class="exp-layout-col" :span="18" :push="6">col-18 push-6</ta-col>
<ta-col class="exp-layout-col" :span="6" :pull="18">col-6 pull-18</ta-col>
</ta-row>
</ta-group>
<ta-group title="水平对齐方式">
<div class="exp-layout-title">justify: start</div>
<ta-row class="exp-layout-row" justify="start">
<ta-col class="exp-layout-col" :span="4">col-4</ta-col>
<ta-col class="exp-layout-col" :span="4">col-4</ta-col>
<ta-col class="exp-layout-col" :span="4">col-4</ta-col>
<ta-col class="exp-layout-col" :span="4">col-4</ta-col>
</ta-row>
<div class="exp-layout-title">justify: center</div>
<ta-row class="exp-layout-row" justify="center">
<ta-col class="exp-layout-col" :span="4">col-4</ta-col>
<ta-col class="exp-layout-col" :span="4">col-4</ta-col>
<ta-col class="exp-layout-col" :span="4">col-4</ta-col>
<ta-col class="exp-layout-col" :span="4">col-4</ta-col>
</ta-row>
<div class="exp-layout-title">justify: end</div>
<ta-row class="exp-layout-row" justify="end">
<ta-col class="exp-layout-col" :span="4">col-4</ta-col>
<ta-col class="exp-layout-col" :span="4">col-4</ta-col>
<ta-col class="exp-layout-col" :span="4">col-4</ta-col>
<ta-col class="exp-layout-col" :span="4">col-4</ta-col>
</ta-row>
<div class="exp-layout-title">justify: space-around</div>
<ta-row class="exp-layout-row" justify="space-around">
<ta-col class="exp-layout-col" :span="4">col-4</ta-col>
<ta-col class="exp-layout-col" :span="4">col-4</ta-col>
<ta-col class="exp-layout-col" :span="4">col-4</ta-col>
<ta-col class="exp-layout-col" :span="4">col-4</ta-col>
</ta-row>
<div class="exp-layout-title">justify: space-between</div>
<ta-row class="exp-layout-row" justify="space-between">
<ta-col class="exp-layout-col" :span="4">col-4</ta-col>
<ta-col class="exp-layout-col" :span="4">col-4</ta-col>
<ta-col class="exp-layout-col" :span="4">col-4</ta-col>
<ta-col class="exp-layout-col" :span="4">col-4</ta-col>
</ta-row>
</ta-group>
<ta-group title="垂直对齐方式">
<div class="exp-layout-title">align: top</div>
<ta-row class="exp-layout-row" justify="space-around" align="top">
<ta-col class="exp-layout-col exp-layout-h-80" :span="4">col-4</ta-col>
<ta-col class="exp-layout-col exp-layout-h-40" :span="4">col-4</ta-col>
<ta-col class="exp-layout-col exp-layout-h-100" :span="4">col-4</ta-col>
<ta-col class="exp-layout-col exp-layout-h-60" :span="4">col-4</ta-col>
</ta-row>
<div class="exp-layout-title">align: middle</div>
<ta-row class="exp-layout-row" justify="space-around" align="middle">
<ta-col class="exp-layout-col exp-layout-h-80" :span="4">col-4</ta-col>
<ta-col class="exp-layout-col exp-layout-h-40" :span="4">col-4</ta-col>
<ta-col class="exp-layout-col exp-layout-h-100" :span="4">col-4</ta-col>
<ta-col class="exp-layout-col exp-layout-h-60" :span="4">col-4</ta-col>
</ta-row>
<div class="exp-layout-title">align: bottom</div>
<ta-row class="exp-layout-row" justify="space-around" align="bottom">
<ta-col class="exp-layout-col exp-layout-h-80" :span="4">col-4</ta-col>
<ta-col class="exp-layout-col exp-layout-h-40" :span="4">col-4</ta-col>
<ta-col class="exp-layout-col exp-layout-h-100" :span="4">col-4</ta-col>
<ta-col class="exp-layout-col exp-layout-h-60" :span="4">col-4</ta-col>
</ta-row>
</ta-group>
</template>
<script lang="ts">
import { defineComponent } from 'vue'
export default defineComponent({
name: 'ExpLayout'
})
</script>
Import
js
import { TaRow, TaCol } from 'tantalum-ui-mobile'
具体的引入方式可以参考引入组件。
Row
Row Props
属性 | 类型 | 默认值 | 必填 | 说明 |
---|---|---|---|---|
gutter | string | number | number[] | 0 | 否 | 栅格间隔,通过数值设置水平间隔,也可以通过数组的形式设置水平和垂直间隔 [水平间隔, 垂直间隔] |
justify | RowJustify | 'start' | 否 | 水平排列方式,可选值:'start', 'end', 'center', 'space-around', 'space-between' |
align | RowAlign | 'top' | 否 | 水平排列方式,可选值:'top', 'middle', 'bottom' |
Row Slots
vue
<ta-row :gutter="10">
<ta-col :span="24">Layout</ta-col>
</ta-row>
Col
Col Props
属性 | 类型 | 默认值 | 必填 | 说明 |
---|---|---|---|---|
span | string | number | 24 | 否 | 栅格占据的列数,可选 1-24 |
offset | string | number | 0 | 否 | 栅格左侧的间隔格数,可选 1-24 |
push | string | number | 0 | 否 | 栅格向右移动格数,可选 1-24 |
pull | string | number | 0 | 否 | 栅格向左移动格数,可选 1-24 |
Col Slots
vue
<ta-row :gutter="10">
<ta-col :span="24">Layout</ta-col>
</ta-row>