更新记录

0.0.2(2025-02-18) 下载此版本

  • chore: 更新依赖

0.0.1(2025-02-18) 下载此版本

  • init

平台兼容性

Vue2 Vue3
×
App 快应用 微信小程序 支付宝小程序 百度小程序 字节小程序 QQ小程序
HBuilderX 4.44 app-vue app-uvue × × × × ×
钉钉小程序 快手小程序 飞书小程序 京东小程序 鸿蒙元服务
× × × × ×
H5-Safari Android Browser 微信浏览器(Android) QQ浏览器(Android) Chrome IE Edge Firefox PC-Safari
× × × ×

lime-space 间距

  • 设置组件之间的间距。
  • 非uvue端使用的是flex gap实现,可能存在兼容问题

安装

插件市场导入即可

代码演示

基础用法

Space 组件会在各个子组件之间设置一定的间距,默认间距为 8px

<l-space>
    <l-button type="primary">品牌色</l-button>
    <l-button type="primary">品牌色</l-button>
    <l-button type="warning">品牌色</l-button>
</l-space>

垂直排列

direction 属性设置为 vertical,可以设置垂直方向排列的间距。

<l-space direction="vertical" :fill="true">
    <l-button type="primary" :data-block="true">品牌色</l-button>
    <l-button type="primary" :data-block="true">品牌色</l-button>
    <l-button type="warning" :data-block="true">品牌色</l-button>
</l-space>

自定义间距

通过调整 size 的值来控制间距的大小。传入 number 类型时,会默认使用 px 单位;也可以传入带有单位的值。

<!-- 20px -->
<l-space :size="20">
    <l-button type="primary">品牌色</l-button>
    <l-button type="primary">品牌色</l-button>
    <l-button type="warning">品牌色</l-button>
</l-space>

<!-- 数组 -->
<l-space :size="[10,20]">
    <l-button type="primary">品牌色</l-button>
    <l-button type="primary">品牌色</l-button>
    <l-button type="warning">品牌色</l-button>
</l-space>

对齐方式

通过调整 align 的值来设置子元素的对齐方式, 可选值为 start, center ,end ,baseline,在水平模式下的默认值为 center

<radio-group @change="onChange" style="flex-direction: row;">
    <radio style="padding: 20rpx" class="radio" value="start">start</radio>
    <radio style="padding: 20rpx" class="radio" value="center">center</radio>
    <radio style="padding: 20rpx" class="radio" value="end">end</radio>
    <radio style="padding: 20rpx" class="radio" value="baseline">baseline</radio>
</radio-group>
<l-space :align="align">
    <l-button type="primary">{{align}}</l-button>
    <view style="padding: 40px 20px; background: #eee">Block</view>
</l-space>
export default {
    data() {
        return {
            align: 'center'
        }
    },
    methods: {
        onChange(e: RadioGroupChangeEvent){
            this.align = e.detail.value
        }
    },
    mounted() {

    }
}

自动换行

在水平模式下, 通过 wrap 属性来控制子元素是否自动换行。

<l-space :wrap="true">
    <l-button type="primary">品牌色</l-button>
    <l-button type="primary">品牌色</l-button>
    <l-button type="primary">品牌色</l-button>
    <l-button type="primary">品牌色</l-button>
    <l-button type="warning">品牌色</l-button>
    <l-button type="warning">品牌色</l-button>
    <l-button type="primary">品牌色</l-button>
    <l-button type="warning">品牌色</l-button>
    <l-button type="warning">品牌色</l-button>
</l-space>

API

Props

参数 说明 类型 默认值
direction 间距方向 vertical | horizontal horizontal
size 间距大小,如 20 20rpx [20, 20],默认单位为 px,支持数组形式来分别设置横向和纵向间距 number | string | number[] | string[] 8
align 设置子元素的对齐方式 start | end | center | baseline -
wrap 是否自动换行,仅适用于水平方向排列 boolean false
fill 是否让 Space 变为一个块级元素,填充整个父元素 boolean false

Slots

名称 说明
default 间距组件内容

隐私、权限声明

1. 本插件需要申请的系统权限列表:

2. 本插件采集的数据、发送的服务器地址、以及数据用途说明:

3. 本插件是否包含广告,如包含需详细说明广告表达方式、展示频率:

许可协议

MIT协议

暂无用户评论。

使用中有什么不明白的地方,就向插件作者提问吧~ 我要提问