2021-12-29 16:44:43 +00:00
|
|
|
::: anchor
|
|
|
|
:::
|
|
|
|
|
2022-02-05 19:19:24 +00:00
|
|
|
::: title 基本介绍
|
|
|
|
:::
|
|
|
|
|
2022-02-14 03:23:25 +00:00
|
|
|
::: describe 语义化的矢量图形。使用图标组件,你需要安装 `@layui/icons-vue` 图标组件包
|
2022-02-05 19:19:24 +00:00
|
|
|
:::
|
|
|
|
|
2021-10-25 17:13:23 +00:00
|
|
|
::: title 基础使用
|
2021-10-19 14:28:44 +00:00
|
|
|
:::
|
|
|
|
|
2022-02-01 13:48:39 +00:00
|
|
|
::: demo 使用 `lay-icon` 标签, 创建图标组件
|
2021-09-26 22:35:26 +00:00
|
|
|
|
|
|
|
<template>
|
|
|
|
<lay-icon type="layui-icon-face-smile"></lay-icon>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { ref } from 'vue'
|
|
|
|
|
|
|
|
export default {
|
|
|
|
setup() {
|
|
|
|
|
|
|
|
return {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
2021-09-27 09:39:35 +00:00
|
|
|
:::
|
2021-09-30 15:49:46 +00:00
|
|
|
|
2021-10-25 17:13:23 +00:00
|
|
|
::: title 图标颜色
|
2021-10-19 14:28:44 +00:00
|
|
|
:::
|
|
|
|
|
2022-02-01 13:48:39 +00:00
|
|
|
::: demo 使用 `color` 属性设置颜色
|
2021-10-15 02:08:04 +00:00
|
|
|
|
|
|
|
<template>
|
|
|
|
<lay-icon type="layui-icon-face-smile" color="red"></lay-icon>
|
|
|
|
<lay-icon type="layui-icon-face-smile" color="orange"></lay-icon>
|
|
|
|
<lay-icon type="layui-icon-face-smile" color="green"></lay-icon>
|
|
|
|
<lay-icon type="layui-icon-face-smile" color="cyan"></lay-icon>
|
|
|
|
<lay-icon type="layui-icon-face-smile" color="blue"></lay-icon>
|
|
|
|
<lay-icon type="layui-icon-face-smile" color="black"></lay-icon>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { ref } from 'vue'
|
|
|
|
|
|
|
|
export default {
|
|
|
|
setup() {
|
|
|
|
|
|
|
|
return {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
:::
|
|
|
|
|
2021-10-25 17:13:23 +00:00
|
|
|
::: title 图标尺寸
|
2021-10-19 14:28:44 +00:00
|
|
|
:::
|
|
|
|
|
2022-02-01 13:48:39 +00:00
|
|
|
::: demo 使用 `size` 属性设置尺寸
|
2021-10-19 14:28:44 +00:00
|
|
|
|
|
|
|
<template>
|
|
|
|
<lay-icon type="layui-icon-star" size="26px" color="red"></lay-icon>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { ref } from 'vue'
|
|
|
|
|
|
|
|
export default {
|
|
|
|
setup() {
|
|
|
|
|
|
|
|
return {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
:::
|
|
|
|
|
2021-12-06 01:35:18 +00:00
|
|
|
|
|
|
|
::: title 图标组件
|
|
|
|
:::
|
|
|
|
|
|
|
|
<br>
|
|
|
|
|
2021-12-07 08:06:36 +00:00
|
|
|
::: describe 在 0.2.4 版本后, 图标支持组件化的调用方式, 首先你需要安装 `@layui/icons-vue` 依赖。
|
2021-12-06 01:35:18 +00:00
|
|
|
:::
|
|
|
|
|
|
|
|
```
|
|
|
|
npm install @layui/icons-vue
|
|
|
|
```
|
|
|
|
|
2021-12-07 08:06:36 +00:00
|
|
|
::: describe 接下来, 你可以像之前使用组件一样去创建图标。
|
|
|
|
:::
|
|
|
|
|
2021-12-06 01:35:18 +00:00
|
|
|
```vue
|
|
|
|
<template>
|
|
|
|
<!-- 组件图标 -->
|
|
|
|
<AlignCenterIcon></AlignCenterIcon>
|
|
|
|
<DiamondIcon></DiamondIcon>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
import { AlignCenterIcon, DiamondIcon } from '@layui/icons-vue';
|
|
|
|
</script>
|
|
|
|
```
|
|
|
|
|
2021-10-25 17:13:23 +00:00
|
|
|
::: title 图标列表
|
2021-10-19 14:28:44 +00:00
|
|
|
:::
|
2021-10-15 02:08:04 +00:00
|
|
|
|
2022-03-31 04:57:46 +00:00
|
|
|
::: demo
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<ul class="site-doc-icon">
|
2022-04-01 15:39:56 +00:00
|
|
|
<li v-for="(layIcon, index) of LayIconList" @click="copy(layIcon.class)">
|
2022-03-31 04:57:46 +00:00
|
|
|
<i :class="[`layui-icon ${layIcon.class}`]"></i>
|
|
|
|
<div class="doc-icon-name">{{ layIcon.name }}</div>
|
|
|
|
<div class="doc-icon-code">&#x{{ iconsUnicode[index] }};</div>
|
|
|
|
<div class="doc-icon-fontclass">{{ layIcon.class }}</div>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
import { onMounted, nextTick, reactive } from 'vue'
|
|
|
|
import { useClipboard, usePermission } from "@vueuse/core";
|
|
|
|
import { layer } from '@layui/layer-vue';
|
|
|
|
import { LayIconList } from '@layui/icons-vue';
|
|
|
|
|
|
|
|
const iconsUnicode = reactive([]);
|
|
|
|
|
2022-04-01 15:39:56 +00:00
|
|
|
function copy(iconClass) {
|
2022-03-31 04:57:46 +00:00
|
|
|
const { isSupported, copy, copied } = useClipboard()
|
|
|
|
const permissionWrite = usePermission('clipboard-write')
|
|
|
|
if (isSupported && permissionWrite.value === 'granted') {
|
|
|
|
copy(iconClass)
|
|
|
|
copied.value = true
|
|
|
|
} else {
|
|
|
|
let inputEl = document.createElement('input')
|
|
|
|
inputEl.value = iconClass
|
|
|
|
document.body.appendChild(inputEl)
|
|
|
|
inputEl.select()
|
|
|
|
document.execCommand('Copy')
|
|
|
|
inputEl.remove()
|
|
|
|
copied.value = true
|
|
|
|
}
|
|
|
|
if (copied.value) {
|
|
|
|
layer.msg(`复制成功  <span style="color:#5FB878;" >${ iconClass }</span>`,
|
|
|
|
{
|
|
|
|
icon: 1,
|
|
|
|
time: 1500,
|
|
|
|
offset:['15%','50%'],
|
|
|
|
isHtmlFragment: true
|
|
|
|
},
|
|
|
|
() => { }
|
|
|
|
)
|
|
|
|
} else {
|
|
|
|
layer.msg('复制失败', { icon: 2, time: 1500, }, () => { })
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function getIconUnicode(iconClass){
|
|
|
|
const iconEl = document.querySelector(`.site-doc-icon > li > .${iconClass}`);
|
|
|
|
const iconBeforeContent = getComputedStyle(iconEl,":before").content;
|
|
|
|
return iconBeforeContent;
|
|
|
|
}
|
|
|
|
onMounted(() => {
|
|
|
|
LayIconList.forEach((icon) => {
|
|
|
|
const unicode = getIconUnicode(icon.class).charCodeAt(1).toString(16); // unicode 10进制转16进制
|
|
|
|
iconsUnicode.push(unicode)
|
|
|
|
});
|
|
|
|
})
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
.site-doc-icon {
|
|
|
|
margin-bottom: 50px;
|
|
|
|
font-size: 0;
|
|
|
|
}
|
|
|
|
.site-doc-icon li .doc-icon-name,
|
|
|
|
.site-doc-icon li .doc-icon-code {
|
|
|
|
color: #c2c2c2;
|
|
|
|
}
|
|
|
|
.site-doc-icon li .doc-icon-fontclass {
|
|
|
|
height: 40px;
|
|
|
|
line-height: 20px;
|
|
|
|
padding: 0 5px;
|
|
|
|
font-size: 13px;
|
|
|
|
color: #333;
|
|
|
|
}
|
|
|
|
.site-doc-icon li {
|
|
|
|
display: inline-block;
|
|
|
|
vertical-align: middle;
|
|
|
|
width: 16.5%;
|
|
|
|
height: 105px;
|
|
|
|
line-height: 25px;
|
|
|
|
padding: 20px 0;
|
|
|
|
margin-right: -1px;
|
|
|
|
margin-bottom: -1px;
|
|
|
|
border: 1px solid #e2e2e2;
|
|
|
|
font-size: 14px;
|
|
|
|
text-align: center;
|
|
|
|
color: #666;
|
|
|
|
transition: all 0.3s;
|
|
|
|
-webkit-transition: all 0.3s;
|
|
|
|
}
|
|
|
|
.site-doc-icon li:hover{
|
|
|
|
background-color: #F6F6F6;
|
|
|
|
}
|
|
|
|
.site-doc-icon li:hover{
|
|
|
|
background-color:red;
|
|
|
|
}
|
|
|
|
.site-doc-icon li .layui-icon {
|
|
|
|
display: inline-block;
|
|
|
|
font-size: 32px;
|
|
|
|
}
|
|
|
|
.anim .site-doc-icon {
|
|
|
|
margin-bottom: 50px;
|
|
|
|
font-size: 0;
|
|
|
|
}
|
|
|
|
.anim .site-doc-icon li {
|
|
|
|
width: 50%;
|
|
|
|
}
|
|
|
|
.anim .site-doc-icon li {
|
|
|
|
display: inline-block;
|
|
|
|
vertical-align: middle;
|
|
|
|
width: 16.5%;
|
|
|
|
height: 105px;
|
|
|
|
line-height: 25px;
|
|
|
|
padding: 20px 0;
|
|
|
|
margin-right: -1px;
|
|
|
|
margin-bottom: -1px;
|
|
|
|
border: 1px solid #e2e2e2;
|
|
|
|
font-size: 14px;
|
|
|
|
text-align: center;
|
|
|
|
color: #666;
|
|
|
|
transition: all 0.3s;
|
|
|
|
-webkit-transition: all 0.3s;
|
|
|
|
}
|
|
|
|
.anim .site-doc-icon li .layui-anim {
|
|
|
|
width: 125px;
|
|
|
|
height: 125px;
|
|
|
|
line-height: 125px;
|
|
|
|
margin: 0 auto 10px;
|
|
|
|
text-align: center;
|
|
|
|
background-color: var(--global-primary-color);
|
|
|
|
cursor: pointer;
|
|
|
|
color: #fff;
|
|
|
|
border-radius: 50%;
|
|
|
|
}
|
|
|
|
.anim .site-doc-icon li .code {
|
|
|
|
white-space: nowrap;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
:::
|
2021-10-01 13:56:59 +00:00
|
|
|
|
2021-10-25 17:13:23 +00:00
|
|
|
::: title 图标属性
|
2021-10-19 14:28:44 +00:00
|
|
|
:::
|
|
|
|
|
2021-11-07 07:55:08 +00:00
|
|
|
::: table
|
|
|
|
|
2021-10-31 17:02:21 +00:00
|
|
|
| 属性 | 描述 | 默认值 |
|
|
|
|
| ------ | ---- | ----------------- |
|
|
|
|
| type | 图标 | `layui-icon-home` |
|
|
|
|
| prefix | 前缀 | `layui-icon` |
|
|
|
|
| color | 颜色 | -- |
|
|
|
|
| size | 尺寸 | -- |
|
2021-11-07 07:55:08 +00:00
|
|
|
|
2021-11-07 07:56:24 +00:00
|
|
|
:::
|
2021-12-16 09:57:59 +00:00
|
|
|
|
2022-01-12 06:19:06 +00:00
|
|
|
::: previousNext iconfont
|
2021-12-16 09:57:59 +00:00
|
|
|
:::
|