1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
| import { h, defineComponent } from "vue";
|
| // 封装iconfont组件,默认`font-class`引用模式,支持`unicode`引用、`font-class`引用、`symbol`引用 (https://www.iconfont.cn/help/detail?spm=a313x.7781069.1998910419.20&helptype=code)
| export default defineComponent({
| name: "FontIcon",
| props: {
| icon: {
| type: String,
| default: ""
| }
| },
| render() {
| const attrs = this.$attrs;
| if (Object.keys(attrs).includes("uni") || attrs?.iconType === "uni") {
| return h(
| "i",
| {
| class: "iconfont",
| ...attrs
| },
| this.icon
| );
| } else if (
| Object.keys(attrs).includes("svg") ||
| attrs?.iconType === "svg"
| ) {
| return h(
| "svg",
| {
| class: "icon-svg"
| },
| {
| default: () => [
| h("use", {
| "xlink:href": `#${this.icon}`
| })
| ]
| }
| );
| } else {
| return h("i", {
| class: `iconfont ${this.icon}`,
| ...attrs
| });
| }
| }
| });
|
|