深色模式
Segment 片段容器
片段容器,为指定内容提供标签设置。
基本用法
点击查看代码
vue
<template>
<s-segment label="姓名" showColon>
<el-input v-model="inputValue" placeholder="请输入" />
</s-segment>
</template>
<script setup lang="ts">
import { ref } from "vue";
const inputValue = ref<string>("");
</script>1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
组件尺寸
点击查看代码
vue
<template>
<s-form showColon>
<s-form-item label="标签位置">
<el-radio-group v-model="segmentSize">
<el-radio v-for="item in sizeOptions" :key="item.value" :value="item.value">{{ item.label }}</el-radio>
</el-radio-group>
</s-form-item>
</s-form>
<s-segment label="姓名" :size="segmentSize" showColon>
<el-input v-model="inputValue" :size="segmentSize" placeholder="请输入" />
</s-segment>
</template>
<script setup lang="ts">
import { ref, reactive } from "vue";
const inputValue = ref<string>("");
const segmentSize = ref<string>("default");
const sizeOptions = reactive<Record<string, any>>([
{ value: "small", label: "小号" },
{ value: "default", label: " 默认" },
{ value: "large", label: "大号" }
]);
</script>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
标签位置
点击查看代码
vue
<template>
<s-form showColon>
<s-form-item label="标签位置">
<el-radio-group v-model="segmentLabelPosition">
<el-radio v-for="item in labelPositionOptions" :key="item.value" :value="item.value">{{ item.label }}</el-radio>
</el-radio-group>
</s-form-item>
</s-form>
<s-segment label="姓名" :label-position="segmentLabelPosition" required showColon>
<el-input v-model="inputValue" placeholder="请输入" />
</s-segment>
</template>
<script setup lang="ts">
import { ref, reactive } from "vue";
const inputValue = ref<string>("");
const segmentLabelPosition = ref<string>("left");
const labelPositionOptions = reactive<Record<string, any>>([
{ value: "left", label: "左侧" },
{ value: "top", label: "上侧" },
{ value: "right", label: "右侧" }
]);
</script>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
标签加粗
点击查看代码
vue
<template>
<s-segment label="姓名" labelBold showColon>
<el-input v-model="inputValue" placeholder="请输入" />
</s-segment>
</template>
<script setup lang="ts">
import { ref } from "vue";
const inputValue = ref<string>("");
</script>1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
行内元素
点击查看代码
vue
<template>
<s-segment label="姓名" inline showColon>
<el-input v-model="inputValue" placeholder="请输入" />
</s-segment>
</template>
<script setup lang="ts">
import { ref } from "vue";
const inputValue = ref<string>("");
</script>1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
必填星号
点击查看代码
vue
<template>
<s-segment label="姓名" required showColon>
<el-input v-model="inputValue" placeholder="请输入" />
</s-segment>
</template>
<script setup lang="ts">
import { ref } from "vue";
const inputValue = ref<string>("");
</script>1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
描述信息
描述信息
点击查看代码
vue
<template>
<s-segment label="姓名" description="描述信息" showColon>
<el-input v-model="inputValue" placeholder="请输入" />
</s-segment>
</template>
<script setup lang="ts">
import { ref } from "vue";
const inputValue = ref<string>("");
</script>1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
错误信息
请输入姓名
描述信息
点击查看代码
vue
<template>
<s-segment label="姓名" :errorMessage="errorMessage" description="描述信息" showColon>
<el-input v-model="inputValue" placeholder="请输入" />
</s-segment>
</template>
<script setup lang="ts">
import { computed, ref } from "vue";
const inputValue = ref<string>("");
const errorMessage = computed(() => !inputValue.value ? "请输入姓名" : undefined);
</script>1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13
提示信息
点击查看代码
vue
<template>
<s-segment label="提示信息" tooltip="提示信息" showColon>
<el-input v-model="inputValue" placeholder="请输入" />
</s-segment>
<br />
<s-segment label="自定义提示" tooltip="提示信息" :tooltipProps="{ effect: 'dark' }" showColon>
<el-input v-model="inputValue" placeholder="请输入" />
</s-segment>
</template>
<script setup lang="ts">
import { ref } from "vue";
const inputValue = ref<string>("");
</script>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17