cmc-web/packages/common/components/icon-select/index.vue

36 lines
851 B
Vue
Raw Normal View History

2024-08-20 12:11:31 +00:00
<template>
<el-select clearable :value="iconName" placeholder="请选择图标" filterable="" @change="change">
<el-option v-for="item in iconData" :key="item" :label="item" :value="item">
<cb-svg-icon :icon-name="item"></cb-svg-icon>
{{ item }}
</el-option>
</el-select>
</template>
<script lang="ts">
import elementIcons from './elementIcons'
import svgIcons from './svgIcons'
import { defineComponent } from 'vue'
export default defineComponent({
model: {
prop: 'iconName',
event: 'change'
},
props: {
iconName: {
required: true
}
},
setup(props, context) {
const iconData = [...svgIcons, ...elementIcons.map((item: any) => `el-icon-${item}`)]
const change = (val: string) => {
context.emit('change', val)
}
return {
iconData,
change
}
}
})
</script>