🐛(select): 修复 typescript 警告
This commit is contained in:
parent
a8237710e2
commit
db21a23bda
@ -17,21 +17,21 @@ import {
|
||||
toRefs,
|
||||
Ref,
|
||||
} from "vue";
|
||||
import LayScroll from "../scroll";
|
||||
import LayBadge from "../badge/index.vue";
|
||||
import LayScroll from "../scroll/index.vue";
|
||||
import { onClickOutside } from "@vueuse/core";
|
||||
import { SelectItem } from "../../types";
|
||||
|
||||
export interface LaySelectProps {
|
||||
modelValue?: string | number | [] | null;
|
||||
name?: string;
|
||||
placeholder?: string;
|
||||
disabled?: boolean;
|
||||
showEmpty?: boolean;
|
||||
emptyMessage?: string;
|
||||
modelValue?: any;
|
||||
multiple?: boolean;
|
||||
create?: boolean;
|
||||
items?: { label: string; value: string | number | [] | null; key: string }[];
|
||||
items?: { label: string; value: any; key: string, disabled: boolean; keyword: string }[];
|
||||
}
|
||||
|
||||
const selectRef = ref<null | HTMLElement>();
|
||||
@ -57,10 +57,10 @@ const open = function () {
|
||||
return;
|
||||
}
|
||||
openState.value = !openState.value;
|
||||
console.log(props.create);
|
||||
};
|
||||
|
||||
const emit = defineEmits(["update:modelValue", "change", "search", "create"]);
|
||||
|
||||
const selectItem = ref<SelectItem>({
|
||||
value: !props.multiple
|
||||
? props.modelValue
|
||||
@ -77,9 +77,7 @@ watch(
|
||||
emit("update:modelValue", val);
|
||||
emit("change", val);
|
||||
},
|
||||
{
|
||||
deep: true,
|
||||
}
|
||||
{ deep: true }
|
||||
);
|
||||
|
||||
watch(props, () => {
|
||||
@ -93,7 +91,7 @@ watch(props, () => {
|
||||
}
|
||||
} else {
|
||||
selectItem.value.value = value;
|
||||
//@ts-ignore
|
||||
//
|
||||
selectItem.value.label = ItemsMap.value[value] || "";
|
||||
}
|
||||
});
|
||||
@ -111,12 +109,12 @@ const value = computed({
|
||||
if (input.value) {
|
||||
return txt.value;
|
||||
}
|
||||
// return txt.value;
|
||||
return !selectItem.value.multiple && selectItem.value.value !== null
|
||||
? selectItem.value.label
|
||||
: null;
|
||||
},
|
||||
});
|
||||
|
||||
const selectItemHandle = async function (
|
||||
_selectItem: SelectItem,
|
||||
isChecked?: boolean
|
||||
@ -163,6 +161,7 @@ const selectItemPush = function (p: SelectItem) {
|
||||
ItemsMap.value[p.value] = p.label;
|
||||
}
|
||||
};
|
||||
|
||||
provide("selectItemHandle", selectItemHandle);
|
||||
provide("selectItemPush", selectItemPush);
|
||||
provide("selectItem", selectItem);
|
||||
@ -227,6 +226,7 @@ provide("keyword", txt);
|
||||
></i>
|
||||
</lay-badge>
|
||||
</template>
|
||||
<input>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -133,7 +133,7 @@ function handleTitleClick(node: TreeData) {
|
||||
>
|
||||
<template v-if="slots.title">
|
||||
<slot name="title" :data="node"></slot>
|
||||
</template>
|
||||
</template>
|
||||
<template v-else>
|
||||
{{ node.title }}
|
||||
</template>
|
||||
|
@ -89,7 +89,7 @@ function handleClick(node: TreeData) {
|
||||
@node-click="handleClick"
|
||||
>
|
||||
<template v-if="slots.title" v-slot:title="{ data }">
|
||||
<slot name="title" :data="data"></slot>
|
||||
<slot name="title" :data="data"></slot>
|
||||
</template>
|
||||
</tree-node>
|
||||
</div>
|
||||
|
@ -18,6 +18,7 @@
|
||||
<ul>
|
||||
<li>[新增] table 组件 expand 插槽, 内容较多不能一次性完全展示时使用, 参数 data 为当前行数据</li>
|
||||
<li>[新增] table 组件 children 字段解析, 当字段中存在 children 时会自动转化为树表, 通过设置 indentSize 以控制每一层的缩进宽度</li>
|
||||
<li>[新增] tree 组件 title 插槽, 参数 data 为当前行数据, 用于自定义节点标题</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
@ -32,7 +32,7 @@
|
||||
>
|
||||
<span
|
||||
>{{ t("home.download") }}:<em class="site-showdowns"
|
||||
>7,668</em
|
||||
>11,504</em
|
||||
></span
|
||||
>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user