feat(projects): 本地svg动态渲染图标

ISSUES CLOSED: #61
This commit is contained in:
Soybean
2022-06-16 01:17:31 +08:00
parent 833018a831
commit c3c975ee11
16 changed files with 1067 additions and 63 deletions

View File

@@ -1,5 +1,6 @@
import { h } from 'vue';
import { Icon } from '@iconify/vue';
import SvgIcon from '@/components/custom/SvgIcon.vue';
/**
* 动态渲染iconify
@@ -17,3 +18,21 @@ export function iconifyRender(icon: string, color?: string, size?: number) {
}
return () => h(Icon, { icon, style });
}
/**
* 动态渲染自定义图标
* @param icon - 图标名称
* @param color - 图标颜色
* @param size - 图标大小
*/
export function customIconRender(icon: string, color?: string, size?: number) {
const style: { color?: string; size?: string } = {};
if (color) {
style.color = color;
}
if (size) {
style.size = `${size}px`;
}
return () => h(SvgIcon, { icon, style });
}