style: 调整
This commit is contained in:
@ -1,65 +0,0 @@
|
|||||||
<!--
|
|
||||||
* @Author: RenXiaoDong
|
|
||||||
* @Date: 2025-06-25 14:02:40
|
|
||||||
-->
|
|
||||||
<template>
|
|
||||||
<a-select
|
|
||||||
v-model="selectedTags"
|
|
||||||
:multiple="multiple"
|
|
||||||
size="medium"
|
|
||||||
:placeholder="placeholder"
|
|
||||||
allow-clear
|
|
||||||
:max-tag-count="3"
|
|
||||||
@change="handleChange"
|
|
||||||
>
|
|
||||||
<a-option v-for="(item, index) in options" :key="index" :value="item.id" :label="item.name">
|
|
||||||
{{ item.name }}
|
|
||||||
</a-option>
|
|
||||||
</a-select>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
import { ref, watch } from 'vue';
|
|
||||||
|
|
||||||
const props = defineProps({
|
|
||||||
modelValue: {
|
|
||||||
type: [Array, String, Number],
|
|
||||||
default: () => [],
|
|
||||||
},
|
|
||||||
multiple: {
|
|
||||||
type: Boolean,
|
|
||||||
default: true,
|
|
||||||
},
|
|
||||||
placeholder: {
|
|
||||||
type: String,
|
|
||||||
default: '全部',
|
|
||||||
},
|
|
||||||
options: {
|
|
||||||
type: Array,
|
|
||||||
default: () => [],
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const emits = defineEmits(['update:modelValue', 'change']);
|
|
||||||
|
|
||||||
const selectedTags = ref(props.multiple ? [] : '');
|
|
||||||
|
|
||||||
// 监听外部传入的值变化
|
|
||||||
watch(
|
|
||||||
() => props.modelValue,
|
|
||||||
(newVal) => {
|
|
||||||
selectedTags.value = newVal;
|
|
||||||
},
|
|
||||||
{ immediate: true },
|
|
||||||
);
|
|
||||||
|
|
||||||
// 监听内部值变化,向外部发送更新
|
|
||||||
watch(selectedTags, (newVal) => {
|
|
||||||
emits('update:modelValue', newVal);
|
|
||||||
});
|
|
||||||
|
|
||||||
const handleChange = (value) => {
|
|
||||||
selectedTags.value = value;
|
|
||||||
emits('change', value);
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
Reference in New Issue
Block a user