[新增] select组件支持传入items属性用于渲染选择项
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user