[新增] select组件支持传入items属性用于渲染选择项

This commit is contained in:
castleiMac
2022-04-03 17:48:09 +08:00
parent 18ee8db079
commit 8b4d0abd3c
3 changed files with 42 additions and 1 deletions

View File

@@ -29,6 +29,7 @@ export interface LaySelectProps {
showEmpty?: boolean;
emptyMessage?: string;
multiple?: boolean;
items?: { label: string, value: string | number | [] | null, key: string }[]
}
const selectRef = ref<null | HTMLElement>(null);
@@ -232,6 +233,15 @@ provide("keyword", txt)
<template v-if="!multiple && showEmpty">
<lay-select-option :value="null" :label="emptyMessage ?? placeholder" />
</template>
<template v-if="props.items">
<lay-select-option
v-for="(v, k) in props.items"
:key="k"
:value="v.value"
:label="v.label"
:keyword="v.keyword"
></lay-select-option>
</template>
<slot></slot>
</dl>
</div>

View File

@@ -10,7 +10,7 @@ import { SelectItem, SelectItemHandle, SelectItemPush } from "../../types";
import { computed, inject, onMounted, Ref, ref } from "vue";
export interface LaySelectOptionProps {
value: string | null | undefined;
value: string | null | undefined | number;
label: string;
keyword?: string;
disabled?: boolean;