{{ item.value }} import { ref } from 'vue';// 接收父组件的传参const props = defineProps({ modelValue: { type: String, }, options: { type: Array }, placeholder: { type: String },});// 触发父组件的方法const emit = defineEmits(['change', 'update:modelValue']);const options = ref(props.options as any);const filterOptions = (val: string) => { console.log("过滤筛选项") options.value = props.options?.filter((item: any) => { return item.value?.indexOf(val) !== -1; });};const onChangeCommand = (val: string) => { console.log("点击菜单项触发的事件回调") emit('update:modelValue', val); emit('change', val); filterOptions(val);};const onInput = (val: string) => { console.log("在 Input 值改变时触发") emit('update:modelValue', val); filterOptions(val);};const onInputChange = (val: string) => { console.log("仅当 modelValue 改变时,当输入框失去焦点或用户按Enter时触发") emit('change', val);};
|