Skip to content
On this page

布局组件

通过基础的 24 分栏,迅速简便地创建布局。

基础用法

basic
basic
basic
basic
basic
basic
basic
<template>
  <div>
    <etu-row>
      <etu-col :span="16"><div class="blue">basic</div></etu-col>
      <etu-col :span="8"><div class="blue">basic</div></etu-col>
    </etu-row>
    <etu-row>
      <etu-col :span="12"><div class="blue">basic</div></etu-col>
      <etu-col :span="12"><div class="blue">basic</div></etu-col>
    </etu-row>
    <etu-row>
      <etu-col :span="8"><div class="blue">basic</div></etu-col>
      <etu-col :span="8"><div class="blue">basic</div></etu-col>
      <etu-col :span="8"><div class="blue">basic</div></etu-col>
    </etu-row>
  </div>
</template>

<style lang="scss">
.blue {
  background-color: skyblue;
}
</style>
<template>
  <div>
    <etu-row>
      <etu-col :span="16"><div class="blue">basic</div></etu-col>
      <etu-col :span="8"><div class="blue">basic</div></etu-col>
    </etu-row>
    <etu-row>
      <etu-col :span="12"><div class="blue">basic</div></etu-col>
      <etu-col :span="12"><div class="blue">basic</div></etu-col>
    </etu-row>
    <etu-row>
      <etu-col :span="8"><div class="blue">basic</div></etu-col>
      <etu-col :span="8"><div class="blue">basic</div></etu-col>
      <etu-col :span="8"><div class="blue">basic</div></etu-col>
    </etu-row>
  </div>
</template>

<style lang="scss">
.blue {
  background-color: skyblue;
}
</style>

分栏间隔

支持列间距。

行提供 gutter 属性来指定列之间的间距,其默认值为0。

gutter
gutter
gutter
<template>
  <div>
    <etu-row :gutter="10">
      <etu-col :span="8"><div class="blue">gutter</div></etu-col>
      <etu-col :span="8"><div class="blue">gutter</div></etu-col>
      <etu-col :span="8"><div class="blue">gutter</div></etu-col>
    </etu-row>
  </div>
</template>

<style lang="scss">
.blue {
  background-color: skyblue;
}
</style>
<template>
  <div>
    <etu-row :gutter="10">
      <etu-col :span="8"><div class="blue">gutter</div></etu-col>
      <etu-col :span="8"><div class="blue">gutter</div></etu-col>
      <etu-col :span="8"><div class="blue">gutter</div></etu-col>
    </etu-row>
  </div>
</template>

<style lang="scss">
.blue {
  background-color: skyblue;
}
</style>

混合布局

通过基础的 1/24 分栏任意扩展组合形成较为复杂的混合布局。

mixin
mixin
mixin
mixin
mixin
mixin
mixin
mixin
mixin
<template>
  <etu-row :gutter="20">
    <etu-col :span="16"><div class="blue">mixin</div></etu-col>
    <etu-col :span="8"><div class="blue">mixin</div></etu-col>
  </etu-row>
  <etu-row :gutter="20">
    <etu-col :span="8"><div class="blue">mixin</div></etu-col>
    <etu-col :span="8"><div class="blue">mixin</div></etu-col>
    <etu-col :span="4"><div class="blue">mixin</div></etu-col>
    <etu-col :span="4"><div class="blue">mixin</div></etu-col>
  </etu-row>
  <etu-row :gutter="20">
    <etu-col :span="4"><div class="blue">mixin</div></etu-col>
    <etu-col :span="16"><div class="blue">mixin</div></etu-col>
    <etu-col :span="4"><div class="blue">mixin</div></etu-col>
  </etu-row>
</template>

<style lang="scss">
.blue {
  background-color: skyblue;
}
</style>
<template>
  <etu-row :gutter="20">
    <etu-col :span="16"><div class="blue">mixin</div></etu-col>
    <etu-col :span="8"><div class="blue">mixin</div></etu-col>
  </etu-row>
  <etu-row :gutter="20">
    <etu-col :span="8"><div class="blue">mixin</div></etu-col>
    <etu-col :span="8"><div class="blue">mixin</div></etu-col>
    <etu-col :span="4"><div class="blue">mixin</div></etu-col>
    <etu-col :span="4"><div class="blue">mixin</div></etu-col>
  </etu-row>
  <etu-row :gutter="20">
    <etu-col :span="4"><div class="blue">mixin</div></etu-col>
    <etu-col :span="16"><div class="blue">mixin</div></etu-col>
    <etu-col :span="4"><div class="blue">mixin</div></etu-col>
  </etu-row>
</template>

<style lang="scss">
.blue {
  background-color: skyblue;
}
</style>

列偏移

您可以指定列偏移量。

通过制定 col 组件的 offset 属性可以指定分栏偏移的栏数

offset
offset
offset
offset
offset
<template>
  <etu-row :gutter="20">
    <etu-col :span="6"><div class="blue">offset</div></etu-col>
    <etu-col :span="6" :offset="6"><div class="blue">offset</div></etu-col>
  </etu-row>
  <etu-row :gutter="20">
    <etu-col :span="6" :offset="6"><div class="blue">offset</div></etu-col>
    <etu-col :span="6" :offset="6"><div class="blue">offset</div></etu-col>
  </etu-row>
  <etu-row :gutter="20">
    <etu-col :span="12" :offset="6"><div class="blue">offset</div></etu-col>
  </etu-row>
</template>

<style>
.blue {
  background-color: skyblue;
}
</style>
<template>
  <etu-row :gutter="20">
    <etu-col :span="6"><div class="blue">offset</div></etu-col>
    <etu-col :span="6" :offset="6"><div class="blue">offset</div></etu-col>
  </etu-row>
  <etu-row :gutter="20">
    <etu-col :span="6" :offset="6"><div class="blue">offset</div></etu-col>
    <etu-col :span="6" :offset="6"><div class="blue">offset</div></etu-col>
  </etu-row>
  <etu-row :gutter="20">
    <etu-col :span="12" :offset="6"><div class="blue">offset</div></etu-col>
  </etu-row>
</template>

<style>
.blue {
  background-color: skyblue;
}
</style>

对齐方式

默认使用 flex 布局来对分栏进行灵活的对齐。

您可以通过justify 属性来定义子元素的排版方式,其取值为start、center、end、space-between、space-around或space-evenly。

flex
flex
flex
flex
flex
flex
flex
flex
flex
flex
flex
flex
flex
flex
flex
flex
flex
flex
<template>
  <etu-row type="flex" justify="start">
    <etu-col :span="6"><div class="blue">flex</div></etu-col>
    <etu-col :span="6"><div class="blue">flex</div></etu-col>
    <etu-col :span="6"><div class="blue">flex</div></etu-col>
  </etu-row>
  <etu-row type="flex" justify="center">
    <etu-col :span="6"><div class="blue">flex</div></etu-col>
    <etu-col :span="6"><div class="blue">flex</div></etu-col>
    <etu-col :span="6"><div class="blue">flex</div></etu-col>
  </etu-row>
  <etu-row type="flex" justify="end">
    <etu-col :span="6"><div class="blue">flex</div></etu-col>
    <etu-col :span="6"><div class="blue">flex</div></etu-col>
    <etu-col :span="6"><div class="blue">flex</div></etu-col>
  </etu-row>
  <etu-row type="flex" justify="space-between">
    <etu-col :span="6"><div class="blue">flex</div></etu-col>
    <etu-col :span="6"><div class="blue">flex</div></etu-col>
    <etu-col :span="6"><div class="blue">flex</div></etu-col>
  </etu-row>
  <etu-row type="flex" justify="space-around">
    <etu-col :span="6"><div class="blue">flex</div></etu-col>
    <etu-col :span="6"><div class="blue">flex</div></etu-col>
    <etu-col :span="6"><div class="blue">flex</div></etu-col>
  </etu-row>
  <etu-row type="flex" justify="space-evenly">
    <etu-col :span="6"><div class="blue">flex</div></etu-col>
    <etu-col :span="6"><div class="blue">flex</div></etu-col>
    <etu-col :span="6"><div class="blue">flex</div></etu-col>
  </etu-row>
</template>

<style>
.blue {
  background-color: skyblue;
}
</style>
<template>
  <etu-row type="flex" justify="start">
    <etu-col :span="6"><div class="blue">flex</div></etu-col>
    <etu-col :span="6"><div class="blue">flex</div></etu-col>
    <etu-col :span="6"><div class="blue">flex</div></etu-col>
  </etu-row>
  <etu-row type="flex" justify="center">
    <etu-col :span="6"><div class="blue">flex</div></etu-col>
    <etu-col :span="6"><div class="blue">flex</div></etu-col>
    <etu-col :span="6"><div class="blue">flex</div></etu-col>
  </etu-row>
  <etu-row type="flex" justify="end">
    <etu-col :span="6"><div class="blue">flex</div></etu-col>
    <etu-col :span="6"><div class="blue">flex</div></etu-col>
    <etu-col :span="6"><div class="blue">flex</div></etu-col>
  </etu-row>
  <etu-row type="flex" justify="space-between">
    <etu-col :span="6"><div class="blue">flex</div></etu-col>
    <etu-col :span="6"><div class="blue">flex</div></etu-col>
    <etu-col :span="6"><div class="blue">flex</div></etu-col>
  </etu-row>
  <etu-row type="flex" justify="space-around">
    <etu-col :span="6"><div class="blue">flex</div></etu-col>
    <etu-col :span="6"><div class="blue">flex</div></etu-col>
    <etu-col :span="6"><div class="blue">flex</div></etu-col>
  </etu-row>
  <etu-row type="flex" justify="space-evenly">
    <etu-col :span="6"><div class="blue">flex</div></etu-col>
    <etu-col :span="6"><div class="blue">flex</div></etu-col>
    <etu-col :span="6"><div class="blue">flex</div></etu-col>
  </etu-row>
</template>

<style>
.blue {
  background-color: skyblue;
}
</style>

Row API

属性名说明类型默认值
gutter栅格间距number0
justifyflex布局下的水平排列方式enumstart
alignflex布局下的垂直排列方式enumtop

Col API

属性名说明类型默认值
span栅格占据的列数number24
offset栅格左侧的间隔格数number0