tempCode
发布时间 2023-11-21 11:25:20作者: 送一轮明月
<template> <div class="dropdown-search"> <el-select v-model="selectedItem" filterable remote :remote-method="handleSearch" :loading="loading" placeholder="输入关键字进行搜索" style="width: 200px" > <el-option v-for="item in filteredItems" :key="item.id" :label="item.name" :value="item.id" /> </el-select> </div> </template> <script> import { ref, computed } from 'vue'; import { ElSelect, ElOption } from 'element-plus'; export default { name: 'DropdownSearch', components: { ElSelect, ElOption, }, props: { items: { type: Array, required: true, }, }, setup(props) { const searchTerm = ref(''); const selectedItem = ref(null); const loading = ref(false); const handleSearch = (searchValue) => { searchTerm.value = searchValue; loading.value = true;