2016-07-27 06:15:02 +00:00
|
|
|
|
<script>
|
|
|
|
|
var iconList = require('examples/icon.json');
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
icons: iconList
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
<style>
|
2016-09-18 14:01:26 +00:00
|
|
|
|
.demo-icon .source > i {
|
|
|
|
|
color: #8492a6;
|
|
|
|
|
margin: 0 20px;
|
2016-09-06 09:26:04 +00:00
|
|
|
|
font-size: 1.5em;
|
|
|
|
|
vertical-align: middle;
|
|
|
|
|
}
|
2016-09-18 14:01:26 +00:00
|
|
|
|
|
|
|
|
|
.demo-icon .source > button {
|
|
|
|
|
margin: 0 20px;
|
|
|
|
|
}
|
2016-09-06 09:26:04 +00:00
|
|
|
|
|
2016-07-27 06:15:02 +00:00
|
|
|
|
.icon-list {
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
list-style: none;
|
|
|
|
|
padding: 0;
|
2016-09-18 14:01:26 +00:00
|
|
|
|
border: solid 1px #eaeefb;
|
|
|
|
|
border-radius: 4px;
|
2016-07-27 06:15:02 +00:00
|
|
|
|
}
|
|
|
|
|
.icon-list li {
|
|
|
|
|
float: left;
|
2016-09-18 14:01:26 +00:00
|
|
|
|
width: 16.66%;
|
2016-07-27 06:15:02 +00:00
|
|
|
|
text-align: center;
|
|
|
|
|
height: 120px;
|
|
|
|
|
line-height: 120px;
|
|
|
|
|
color: #666;
|
|
|
|
|
font-size: 13px;
|
|
|
|
|
transition: color .15s linear;
|
|
|
|
|
|
|
|
|
|
border-right: 1px solid #eee;
|
|
|
|
|
border-bottom: 1px solid #eee;
|
|
|
|
|
margin-right: -1px;
|
|
|
|
|
margin-bottom: -1px;
|
|
|
|
|
|
|
|
|
|
@utils-vertical-center;
|
|
|
|
|
|
|
|
|
|
& span {
|
|
|
|
|
display: inline-block;
|
|
|
|
|
line-height: normal;
|
|
|
|
|
vertical-align: middle;
|
2016-09-18 14:01:26 +00:00
|
|
|
|
font-family: 'Helvetica Neue',Helvetica,'PingFang SC','Hiragino Sans GB','Microsoft YaHei',SimSun,sans-serif;
|
|
|
|
|
color: #99a9bf;
|
2016-07-27 06:15:02 +00:00
|
|
|
|
}
|
|
|
|
|
& i {
|
|
|
|
|
display: block;
|
2016-09-18 14:01:26 +00:00
|
|
|
|
font-size: 24px;
|
2016-07-27 06:15:02 +00:00
|
|
|
|
margin-bottom: 15px;
|
2016-09-18 14:01:26 +00:00
|
|
|
|
color: #8492a6;
|
2016-07-27 06:15:02 +00:00
|
|
|
|
}
|
|
|
|
|
&:hover {
|
|
|
|
|
color: rgb(92, 182, 255);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|
2016-08-26 10:34:54 +00:00
|
|
|
|
## Icon 图标
|
2016-07-27 06:15:02 +00:00
|
|
|
|
|
2016-08-18 09:29:11 +00:00
|
|
|
|
提供了一套常用的图标集合。
|
2016-07-27 06:15:02 +00:00
|
|
|
|
|
2016-09-06 11:30:50 +00:00
|
|
|
|
### 使用方法
|
2016-07-27 06:15:02 +00:00
|
|
|
|
|
2016-09-07 10:46:20 +00:00
|
|
|
|
直接通过设置类名为 `el-icon-iconName` 来使用即可。例如:
|
2016-07-27 06:15:02 +00:00
|
|
|
|
|
2016-08-25 10:24:51 +00:00
|
|
|
|
:::demo
|
2016-07-27 06:15:02 +00:00
|
|
|
|
```html
|
2016-09-06 09:26:04 +00:00
|
|
|
|
<i class="el-icon-edit"></i>
|
|
|
|
|
<i class="el-icon-share"></i>
|
|
|
|
|
<i class="el-icon-delete"></i>
|
2016-07-27 06:15:02 +00:00
|
|
|
|
<el-button type="primary" icon="search">搜索</el-button>
|
2016-08-25 10:24:51 +00:00
|
|
|
|
|
2016-07-27 06:15:02 +00:00
|
|
|
|
```
|
2016-08-25 10:24:51 +00:00
|
|
|
|
:::
|
2016-07-27 06:15:02 +00:00
|
|
|
|
|
2016-09-06 11:30:50 +00:00
|
|
|
|
### 图标集合
|
2016-07-27 06:15:02 +00:00
|
|
|
|
|
|
|
|
|
<ul class="icon-list">
|
2017-04-28 06:03:42 +00:00
|
|
|
|
<li v-for="name in icons" :key="name">
|
2016-07-27 06:15:02 +00:00
|
|
|
|
<span>
|
|
|
|
|
<i :class="'el-icon-' + name"></i>
|
|
|
|
|
{{'el-icon-' + name}}
|
|
|
|
|
</span>
|
|
|
|
|
</li>
|
|
|
|
|
</ul>
|
2017-08-10 10:07:40 +00:00
|
|
|
|
|
|
|
|
|
### 第三方图标库
|
|
|
|
|
|
|
|
|
|
Element 的一些组件提供了 `icon` 属性(如 Input),如果希望传入第三方图标库中的图标,需要进行如下操作:
|
|
|
|
|
<p>
|
|
|
|
|
<span>1.</span> 修改第三方图标库的前缀(见下方说明)
|
|
|
|
|
</p>
|
|
|
|
|
<p>
|
|
|
|
|
<span>2.</span> 添加以下 CSS:
|
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
```CSS
|
|
|
|
|
[class^="el-icon-my"], [class*=" el-icon-my"] {
|
|
|
|
|
font-family:"your-font-family" !important;
|
|
|
|
|
|
|
|
|
|
/* 以下内容参照第三方图标库本身的规则 */
|
|
|
|
|
font-size: inherit;
|
|
|
|
|
font-style:normal;
|
|
|
|
|
-webkit-font-smoothing: antialiased;
|
|
|
|
|
-moz-osx-font-smoothing: grayscale;
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
之后就可以像使用 Element 内置图标一样使用第三方图标。比如在 el-input 中:
|
|
|
|
|
|
|
|
|
|
```html
|
|
|
|
|
<el-input icon="my-xxx" />
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
关于如何修改第三方图标库的前缀,请参阅第三方图标库的文档。比如,如果使用 [iconfont.cn](http://iconfont.cn/),则可以在「编辑项目」弹框中修改;如果使用 [Font Awesome](http://fontawesome.io/),可以参考[这个示例](https://github.com/ElementUI/element-font-awesome)。
|