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
| <template>
| <span class="mars-icon" v-html="svgComponent"></span>
| </template>
| <script lang="ts">
| import { computed, useAttrs, defineComponent } from "vue"
| import * as svgModule from "@icon-park/svg"
| import _ from "lodash"
| export default defineComponent({
| name: "mars-icon",
| // inheritAttrs: false,
| props: {
| icon: {
| type: String
| },
| color: {
| type: String,
| default: "#fff"
| },
| width: {
| type: [String, Number],
| default: "14"
| }
| },
| setup(props) {
| const attrs = useAttrs()
| const iconName = computed(() => _.upperFirst(_.camelCase(props.icon)))
|
| const svgComponent = svgModule[iconName.value]({
| theme: "outline",
| fill: props.color,
| size: props.width,
| ...attrs
| })
|
| return {
| attrs,
| svgComponent
| }
| }
| })
| </script>
| <style lang="less" scoped>
| .mars-icon {
| vertical-align: middle;
| }
| </style>
|
|