当前位置: 首页 > news >正文

vue element plus Space 间距

虽然我们拥有 Divider 组件,但很多时候我们需要不是一个被 Divider 组件 分割开的页面结构,因此我们会重复的使用很多的 Divider 组件,这在我们的开发效率上造成了一定的困扰。 间距组件就是为了解决这种困扰应运而生的。

基础用法#

最基础的用法,通过这个组件来给组件之间提供统一的间距。

通过间距组件来给多个组件之间提供间距

Card nameOperation button

List item 1

List item 2

List item 3

List item 4

Card nameOperation button

List item 1

List item 2

List item 3

List item 4

Card nameOperation button

List item 1

List item 2

List item 3

List item 4

垂直布局#

使用 direction 来控制布局的方式, 背后实际上是利用了 flex-direction 来控制.

我们也提供垂直布局方式。

Card nameOperation button

List item 1

List item 2

List item 3

List item 4

Card nameOperation button

List item 1

List item 2

List item 3

List item 4

控制间距的大小#

通过调整 size 的值来控制间距的大小

使用内置的 smalldefaultlarge 来设置间距大小,分别对应 8px12px 和 16px 的间距。 默认的间距大小为 small,也就是 8px

您也可以通过自定义的 size 来控制大小, 参见下一个部分。

largedefaultsmall

Card nameOperation button

List item 1

List item 2

List item 3

List item 4

Card nameOperation button

List item 1

List item 2

List item 3

List item 4

Card nameOperation button

List item 1

List item 2

List item 3

List item 4

自定义 Size#

很多时候,内建的大小不满足设计师的要求,我们可以通过传入自己定义的大小 (数值类型) 来设置。

Card nameOperation button

List item 1

List item 2

List item 3

List item 4

Card nameOperation button

List item 1

List item 2

List item 3

List item 4

TIP

不要让 ElSpace 与使用依赖父元素百分比宽度(或高度)的元素一起使用(例如 ElSlider),这样会造成光标不同步。

自动换行#

在 水平 (horizontal) ** 模式下, 通过控制 wrap(布尔类型)**来控制是否自动换行

利用 wrap 属性控制换行

Text button

Text button

Text button

Text button

Text button

Text button

Text button

Text button

Text button

Text button

Text button

Text button

Text button

Text button

Text button

Text button

Text button

Text button

Text button

Text button

行间分隔符#

有时候,仅仅在行间加空白并不能满足我们的日常需求,此时分隔符 (spacer) 就可以发挥非常好的作用了。

字母数字类型分隔符#

button 1

|

button 2

分隔符还可以是 VNode 类型#

button 1

button 2

对齐方式#

设置该值可以调整所有子节点在容器内的对齐方式,可设置的值与 align-items一致。

使用 alignment 属性来对齐

string

button

header

body

string

button

header

body

string

button

header

body

填充容器#

通过 fill**(布尔类型)**参数,您可以控制子节点是否自动填充容器。

下面的例子中,当设置为 fill 时,子节点的宽度会自动适配容器的宽度。

用 fill 属性让子节点自动填充容器

fill: 

Card nameOperation button

List item 1

List item 2

List item 3

List item 4

Card nameOperation button

List item 1

List item 2

List item 3

List item 4

Card nameOperation button

List item 1

List item 2

List item 3

List item 4

也可以使用 fillRatio 参数,自定义填充的比例, 默认值为 100,代表基于父容器宽度的 100% 进行填充

需要注意的是,水平布局和垂直布局的表现形式稍有不同,具体的效果可以查看下面的例子

用 fillRatio 自定义填充比例

direction: horizontalvertical

fillRatio:

Card nameOperation button

List item 1

List item 2

List item 3

List item 4

Card nameOperation button

List item 1

List item 2

List item 3

List item 4

Card nameOperation button

List item 1

List item 2

List item 3

List item 4

Card nameOperation button

List item 1

List item 2

List item 3

List item 4

Card nameOperation button

List item 1

List item 2

List item 3

List item 4

API#

Attributes#

属性名说明类型默认值
alignment对齐的方式enum align-itemscenter
class类名string / object / array
direction排列的方向enumhorizontal
prefix-cls给 space-items 的类名前缀string
style额外样式string / object
spacer间隔符string / number / VNode
size间隔大小enum / number / arraysmall
wrap设置是否自动折行booleanfalse
fill子元素是否填充父容器booleanfalse
fill-ratio填充父容器的比例number100

Slots#

名称说明
default需要添加间隔的元素

源代码#

组件 • 文档

http://www.lryc.cn/news/277394.html

相关文章:

  • 【驱动序列】C#获取电脑硬件之CPU信息,以及它都有那些品牌
  • 目标检测-One Stage-YOLO v3
  • 安泰ATA-4014高压功率放大器在传感器脉冲涡流检测中的应用
  • Axure全面指南:正确打开并高效使用的步骤!
  • ts axios 指定返回值类型,返回数据类型不确定该怎么办 typescript
  • 判断是否是json字符串
  • SpringBoot集成Minio(接上文)
  • 更新 torchtext 造成的torch版本不匹配的问题
  • flutter资源
  • C++经典程序
  • Java多线程-Thread类的run方法
  • java基础之Java8新特性-方法引入
  • K8S中的hostPort、NodePort 、targetPort、port、containerPort 的区别
  • SpringBoot整合FreeMarker模板引擎
  • 编程基础 - 变量与常量
  • Linux入门攻坚——12、Linux网络属性配置相关知识2
  • 如何自己实现一个分布式事务
  • 使用Nonebot编写QQ机器人
  • 认识SpringBoot中的条件注解
  • 使用PAI-DSW搭建基于LangChain的检索知识库问答机器人
  • 优雅的通过Shell脚本生成Go的程序包
  • 益生菌抗癌?补充这种益生菌,抑制肝癌,还改善肠道健康
  • LLM漫谈(二)| QAnything支持任意格式文件或数据库的本地知识库问答系统
  • Linux环境vscode clang-format格式化:vscode clang format command is not available亲测有效!
  • Vue3前端 响应式数据 知识点
  • golang数据库连接池设置多少比较合适,如何设置?
  • 一、Mybatis 简介
  • 苹果Vision Pro将于1月27日上市!
  • 密码学(一)
  • VueRouter