Skip to content

面板分割 Split

将面板分割成两部分。

基本用法

将一个面板分割成两个可以调整宽度或高度的两部分。用direction控制分割方向。


代码事例
vue
<template>
	<div>
		<fk-split
			v-model:size="size"
			:style="{
				height: '200px',
				width: '100%',
				minWidth: '500px',
				border: '1px solid var(--color-border)',
			}"
			min="80px"
		>
			<template #first>
				<fk-typography-paragraph>Left</fk-typography-paragraph>
			</template>
			<template #second>
				<fk-typography-paragraph>Right</fk-typography-paragraph>
			</template>
		</fk-split>
	</div>
</template>
<script>
export default {
	data() {
		return {
			size: 0.5,
		};
	},
};
</script>

面板分割嵌套

面板分割可以嵌套使用。


代码事例
vue
<template>
	<div>
		<fk-split
			:style="{
				height: '200px',
				width: '100%',
				minWidth: '500px',
				border: '1px solid var(--color-border)',
			}"
		>
			<template #first>
				<fk-typography-paragraph>Left</fk-typography-paragraph>
			</template>
			<template #second>
				<div>
					<fk-split direction="vertical" :style="{ height: '200px' }">
						<template #first><fk-typography-paragraph>Top</fk-typography-paragraph></template>
						<template #second><fk-typography-paragraph>Bottom</fk-typography-paragraph></template>
					</fk-split>
				</div>
			</template>
		</fk-split>
	</div>
</template>

API

<split> Props

参数名描述类型默认值
component分割框的 html 标签string'div'
direction分割的方向'horizontal' | 'vertical''horizontal'
size (v-model)分割的大小,可以是 0~1 代表百分比,或具体数值的像素,如 300pxnumber|string-
default-size默认分割的大小,可以是 0~1 代表百分比,或具体数值的像素,如 300pxnumber|string0.5
min最小阈值,可以是 0~1 代表百分比,或具体数值的像素,如 300pxnumber|string-
max最大阈值,可以是 0~1 代表百分比,或具体数值的像素,如 300pxnumber|string-
disabled是否禁用booleanfalse

<split> Events

事件名描述参数
move-start开始拖拽之前触发-
moving拖拽时触发-
move-end拖拽结束之后触发-

<split> Slots

插槽名描述参数
first第一个面板的内容-
resize-trigger伸缩杆的内容-
resize-trigger-icon伸缩杆的图标-
second第二个面板的内容-

基于 MIT 许可发布