🐛(component): 修复 select 组件多选无法被删除的问题

This commit is contained in:
就眠儀式 2022-10-08 14:03:05 +08:00
parent 47bc300712
commit 8021404c34

View File

@ -26,6 +26,7 @@ import LayDropdown from "../dropdown/index.vue";
import LaySelectOption, { import LaySelectOption, {
LaySelectOptionProps, LaySelectOptionProps,
} from "../selectOption/index.vue"; } from "../selectOption/index.vue";
import { arrayExpression } from "@babel/types";
export interface LaySelectProps { export interface LaySelectProps {
name?: string; name?: string;
@ -93,6 +94,12 @@ const intOption = () => {
Object.assign(options.value, props.items); Object.assign(options.value, props.items);
}; };
const handleRemove = (value: any) => {
if(Array.isArray(selectedValue.value)) {
selectedValue.value = selectedValue.value.filter(item => item != value);
}
}
onMounted(() => { onMounted(() => {
intOption(); intOption();
timer = setInterval(intOption, 500); timer = setInterval(intOption, 500);
@ -178,6 +185,7 @@ provide("multiple", multiple);
:size="size" :size="size"
:class="{ 'layui-unselect': true }" :class="{ 'layui-unselect': true }"
@clear="handleClear" @clear="handleClear"
@remove="handleRemove"
> >
<template #suffix> <template #suffix>
<lay-icon <lay-icon