# 2 25.封装自定义下拉图标组件

* #### 下拉组件图标封装

```js
<template>
    <div class="flex items-center">
        <el-icon :size="20" v-if="modelValue" class="mr-2">
                <component :is="modelValue"></component>
        </el-icon>


        <el-select filterable :modelValue="modelValue" placeholder="请选择图标" @change="handleChange">
            <el-option v-for="item in icons"
                :key="item"
                :label="item"
                :value="item">

                <div class="flex items-center justify-between">
                    <el-icon>
                        <component :is='item'></component>
                    </el-icon>
                    <span class="text-gray-500">{{ item }}</span>
                </div>

            </el-option>
        </el-select>
        
        
    </div>
</template>

<script setup>
import { ref } from "vue"
import * as iconList from '@element-plus/icons-vue'

const icons = ref(Object.keys(iconList))

const emit = defineEmits(['update:modelValue'])


const handleChange = (icon) => {
    emit('update:modelValue', icon)
}

defineProps({
    modelValue: String
})

</script>
```

* #### 调用

```js
<IconSelect v-model="form.icon" ></IconSelect>
```

<div><img src="C:%5CUsers%5CAdministrator.DESKTOP-UK43ECI%5CAppData%5CRoaming%5Cmarktext%5Cimages%5C2023-02-25-19-44-34-image.png" alt=""> <figure><img src="/files/gFnOTXzhXdQD936bY8mn" alt=""><figcaption></figcaption></figure></div>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://close.gitbook.io/yun-wei-bi-ji/centos/vue/xiang-mu/2-25.-feng-zhuang-zi-ding-yi-xia-la-tu-biao-zu-jian.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
