提交 | 用户 | 时间
|
759b1c
|
1 |
<!-- @author zhengjie --> |
H |
2 |
<template> |
|
3 |
<div class="icon-body"> |
|
4 |
<el-input v-model="name" style="position: relative;" clearable placeholder="请输入图标名称" @clear="filterIcons" @input.native="filterIcons"> |
|
5 |
<i slot="suffix" class="el-icon-search el-input__icon" /> |
|
6 |
</el-input> |
|
7 |
<div class="icon-list"> |
|
8 |
<div v-for="(item, index) in iconList" :key="index" @click="selectedIcon(item)"> |
|
9 |
<svg-icon :icon-class="item" style="height: 30px;width: 16px;" /> |
|
10 |
<span>{{ item }}</span> |
|
11 |
</div> |
|
12 |
</div> |
|
13 |
</div> |
|
14 |
</template> |
|
15 |
|
|
16 |
<script> |
|
17 |
import icons from './requireIcons' |
|
18 |
export default { |
|
19 |
name: 'IconSelect', |
|
20 |
data() { |
|
21 |
return { |
|
22 |
name: '', |
|
23 |
iconList: icons |
|
24 |
} |
|
25 |
}, |
|
26 |
methods: { |
|
27 |
filterIcons() { |
|
28 |
this.iconList = icons |
|
29 |
if (this.name) { |
|
30 |
this.iconList = this.iconList.filter(item => item.includes(this.name)) |
|
31 |
} |
|
32 |
}, |
|
33 |
selectedIcon(name) { |
|
34 |
this.$emit('selected', name) |
|
35 |
document.body.click() |
|
36 |
}, |
|
37 |
reset() { |
|
38 |
this.name = '' |
|
39 |
this.iconList = icons |
|
40 |
} |
|
41 |
} |
|
42 |
} |
|
43 |
</script> |
|
44 |
|
|
45 |
<style rel="stylesheet/scss" lang="scss" scoped> |
|
46 |
.icon-body { |
|
47 |
width: 100%; |
|
48 |
padding: 10px; |
|
49 |
.icon-list { |
|
50 |
height: 200px; |
|
51 |
overflow-y: scroll; |
|
52 |
div { |
|
53 |
height: 30px; |
|
54 |
line-height: 30px; |
|
55 |
margin-bottom: -5px; |
|
56 |
cursor: pointer; |
|
57 |
width: 33%; |
|
58 |
float: left; |
|
59 |
} |
|
60 |
span { |
|
61 |
display: inline-block; |
|
62 |
vertical-align: -0.15em; |
|
63 |
fill: currentColor; |
|
64 |
overflow: hidden; |
|
65 |
} |
|
66 |
} |
|
67 |
} |
|
68 |
</style> |