diff --git a/example/docs/zh-CN/components/select.md b/example/docs/zh-CN/components/select.md
index 6433675f..5e2ac081 100644
--- a/example/docs/zh-CN/components/select.md
+++ b/example/docs/zh-CN/components/select.md
@@ -188,6 +188,44 @@ export default {
+:::
+
+::: title 传入create属性和接收create事件用于开启创建子项功能
+:::
+
+::: demo
+
+
+
+
+ 当前元素: {{items.map(o=>o.label).join()}}
+
+
+
+
+
:::
::: title 海量数据
@@ -283,6 +321,7 @@ export default {
| disabled | 是否禁用 | `boolean` | `true` `false` | `false` |
| showEmpty | 是否增加空提示选项 | `boolean` | `true` `false` | `true` |
| multiple | 是否为多选 | `boolean` | `true` `false` | `false` |
+| create | 是否允许创建 | `boolean` | `true` `false` | `false` |
:::
@@ -296,6 +335,7 @@ export default {
| ------ | ---------- | --------------- |
| change | 切换事件 | value |
| search | 关键词变化事件 | 用户输入的关键词 string |
+| create | 允许创建情况下的创建回调事件 | 用户输入的关键词 string |
:::
diff --git a/src/component/select/index.vue b/src/component/select/index.vue
index 680fda97..f5472caa 100644
--- a/src/component/select/index.vue
+++ b/src/component/select/index.vue
@@ -29,6 +29,7 @@ export interface LaySelectProps {
showEmpty?: boolean;
emptyMessage?: string;
multiple?: boolean;
+ create?: boolean;
items?: { label: string, value: string | number | [] | null, key: string }[]
}
@@ -44,6 +45,7 @@ const props = withDefaults(defineProps(), {
disabled: false,
showEmpty: true,
multiple: false,
+ create: false
});
const openState = ref(false);
@@ -55,9 +57,10 @@ const open = function () {
return;
}
openState.value = !openState.value;
+ console.log(props.create)
};
-const emit = defineEmits(["update:modelValue", "change", 'search']);
+const emit = defineEmits(["update:modelValue", "change", 'search', 'create']);
const selectItem = ref({
value: !props.multiple
? props.modelValue
@@ -114,7 +117,7 @@ const value = computed({
: null
}
})
-const selectItemHandle = function (
+const selectItemHandle = async function (
_selectItem: SelectItem,
isChecked?: boolean
) {
@@ -230,9 +233,12 @@ provide("keyword", txt)
-
+
+
+ - {{ txt }}
+