Appearance
xtf-space
组件说明
xtf-space 是间距布局,用于通过数据包装稳定排列横向、纵向、换行和分隔内容。当前实现读取 items 数据。
- 实际 Demo 路由:
#/pages/components/xtf-space/index - Demo 源码
基础用法
1. 横向换行
数据模式为每一项生成包装节点,通过 margin 实现跨端稳定间距;开启 wrap 后同时应用行间距。
vue
<template>
<view class="doc-space-wrap">
<XtfSpace :items="fixture" wrap block :gap="20" :row-gap="12"><template #item="slotProps"><text class="doc-content-text" @click="logItem(slotProps.item)">{{ slotProps.item }}</text></template></XtfSpace>
</view>
</template>
<script setup lang="uts">
import XtfSpace from "@/uni_modules/xtf-linkuiunix/components/xtf-space/xtf-space.uvue"
const fixture = ['待处理', '已付款', '配送中', '已完成'] as Array<string>
function logItem(item: any): void { console.log("space item", item) }
</script>
<style>
.doc-space-wrap { display: flex; flex-direction: column; padding: 24rpx; }
.doc-content-text { color: #334155; font-size: 26rpx; }
</style>2. 纵向排列
切换为 vertical 后按纵向 margin 排列数据项,并可让内容拉伸到容器宽度。
vue
<template>
<view class="doc-space-vertical">
<XtfSpace :items="fixture" direction="vertical" align="stretch" block :gap="18"><template #item="slotProps"><text class="doc-content-text" @click="logItem(slotProps.item)">{{ slotProps.index + 1 }}. {{ slotProps.item }}</text></template></XtfSpace>
</view>
</template>
<script setup lang="uts">
import XtfSpace from "@/uni_modules/xtf-linkuiunix/components/xtf-space/xtf-space.uvue"
const fixture = ['待处理', '已付款', '配送中', '已完成'] as Array<string>
function logItem(item: any): void { console.log("vertical item", item) }
</script>
<style>
.doc-space-vertical { display: flex; flex-direction: column; padding: 24rpx; }
.doc-content-text { color: #334155; font-size: 26rpx; }
</style>3. 分隔内容
非换行模式下可在相邻数据项之间渲染 separator slot。items 为空时 default slot 只负责排列容器,无法跨端自动为任意 slot 子节点注入间距。
vue
<template>
<view class="doc-space-separator">
<XtfSpace :items="fixture" block justify="center"><template #item="slotProps"><text class="doc-content-text" @click="logItem(slotProps.item)">{{ slotProps.item }}</text></template><template #separator="slotProps"><text class="doc-content-text">{{ slotProps.index < fixture.length - 1 ? "/" : "" }}</text></template></XtfSpace>
</view>
</template>
<script setup lang="uts">
import XtfSpace from "@/uni_modules/xtf-linkuiunix/components/xtf-space/xtf-space.uvue"
const fixture = ['待处理', '已付款', '配送中', '已完成'] as Array<string>
function logItem(item: any): void { console.log("separated item", item) }
</script>
<style>
.doc-space-separator { display: flex; flex-direction: column; padding: 24rpx; }
.doc-content-text { color: #334155; font-size: 26rpx; }
</style>全部属性
| 属性 | 源码类型 | withDefaults 默认值 | 实际行为 / 范围 | 适用范围 |
|---|---|---|---|---|
items | Array<any> | () => [] as Array<any> | 参与组件运行逻辑;源码在 3 处读取该值;消费位置:script 行 43、template 行 3、template 行 4 | 数据驱动或选项渲染场景。 |
direction | "horizontal" | "vertical" | "horizontal" | 参与组件运行逻辑;源码在 3 处读取该值;可选值:horizontal / vertical;消费位置:script 行 41、script 行 47、script 行 50 | 需要覆盖组件默认业务值时设置。 |
gap | string | number | 16 | 参与组件运行逻辑;源码在 1 处读取该值;消费位置:script 行 37 | 需要覆盖组件默认业务值时设置。 |
rowGap | string | number | "" | 参与组件运行逻辑;源码在 2 处读取该值;消费位置:script 行 38 | 需要调整布局或视觉表现时设置。 |
wrap | boolean | false | 参与组件运行逻辑;源码在 3 处读取该值;消费位置:script 行 41、script 行 43、script 行 46 | 需要覆盖组件默认业务值时设置。 |
align | "start" | "center" | "end" | "stretch" | "center" | 参与组件运行逻辑;源码在 1 处读取该值;可选值:start / center / end / stretch;消费位置:script 行 41 | 需要调整布局或视觉表现时设置。 |
justify | "start" | "center" | "end" | "between" | "around" | "start" | 参与组件运行逻辑;源码在 1 处读取该值;可选值:start / center / end / between / around;消费位置:script 行 41 | 需要覆盖组件默认业务值时设置。 |
block | boolean | false | 参与组件运行逻辑;源码在 1 处读取该值;消费位置:script 行 41 | 需要覆盖组件默认业务值时设置。 |
customClass | string | "" | 参与组件运行逻辑;源码在 1 处读取该值;消费位置:script 行 41 | 需要调整布局或视觉表现时设置。 |
customStyle | string | UTSJSONObject | "" | 参与组件运行逻辑;源码在 1 处读取该值;消费位置:template 行 2 | 需要调整布局或视觉表现时设置。 |
事件
| 事件名称 | 源码触发边界 | 回调参数 | 参数说明 |
|---|---|---|---|
| - | 当前组件未调用 defineEmits。 | - | - |
插槽
| 插槽 | Scope 参数 | 实际渲染位置 |
|---|---|---|
default | (props: {}) | 仅在模板对应 <slot> 渲染位置生效。 |
item | (props: { item: any; index: number }) | 仅在模板对应 <slot> 渲染位置生效。 |
separator | (props: { index: number }) | 仅在模板对应 <slot> 渲染位置生效。 |
方法
实例方法
| 方法 | 签名 / 返回值 | 调用边界 |
|---|---|---|
| - | - | 当前组件没有公开实例方法。 |
公开状态
| 状态 | 类型 / 包装 | 读取边界 |
|---|---|---|
| - | - | 当前组件没有公开状态。 |
主题说明
- 当前组件 CSS 未读取
var(--xtf-*)主题变量;颜色或尺寸可能来自 props、固定样式或父级上下文。
平台与实现边界
- 基线为 HBuilderX 5.26+ 与 uni-app x;当前报告已验证 Web Chromium 的对应 Demo,不据此承诺 Safari、小程序或 App 原生端等价。
- Android、iOS、HarmonyOS、Vapor 原生路径、触摸手势、字体、Canvas、安全区和系统权限能力,只有源码或完整性报告明确覆盖的部分才可视为已验证。
- 本文按当前源码生成,不补入旧版
xtf-linkui存在但迁移版未实现的 props、事件、slot 或方法。 - 详细公共边界见 平台与实现边界,逐项运行证据见项目根目录 COMPONENT_COMPLETENESS.md。