2023-03-28 18:04:49 +08:00
|
|
|
<template>
|
2023-03-29 14:38:43 +08:00
|
|
|
<!-- <svg class="svg-icon" :class="svgClass" xmlns="http://www.w3.org/2000/svg"> -->
|
|
|
|
<!-- <use :xlink:href="iconName" xmlns:xlink="http://www.w3.org/1999/xlink" /> -->
|
|
|
|
|
|
|
|
<svg class="svg-icon" :class="className" xmlns="http://www.w3.org/2000/svg">
|
|
|
|
<use :xlink:href="`#icon-${iconClass}`" xmlns:xlink="http://www.w3.org/1999/xlink" />
|
2023-03-28 18:04:49 +08:00
|
|
|
</svg>
|
|
|
|
</template>
|
|
|
|
<script>
|
2023-03-29 14:38:43 +08:00
|
|
|
export default {
|
|
|
|
name: 'SvgIcon',
|
|
|
|
props: {
|
|
|
|
iconClass: {
|
|
|
|
type: String,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
className: {
|
|
|
|
type: String,
|
|
|
|
default: ''
|
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
iconName() {
|
|
|
|
return `#icon-${this.iconClass}`;
|
2023-03-28 18:04:49 +08:00
|
|
|
},
|
2023-03-29 14:38:43 +08:00
|
|
|
svgClass() {
|
|
|
|
if (this.className) {
|
|
|
|
return 'svg-icon ' + this.className;
|
|
|
|
} else {
|
|
|
|
return 'svg-icon';
|
2023-03-28 18:04:49 +08:00
|
|
|
}
|
|
|
|
}
|
2023-03-29 14:38:43 +08:00
|
|
|
}
|
|
|
|
};
|
2023-03-28 18:04:49 +08:00
|
|
|
</script>
|
|
|
|
<style scoped>
|
2023-03-29 14:38:43 +08:00
|
|
|
.svg-icon {
|
|
|
|
/* width: 100%;
|
2023-03-28 18:04:49 +08:00
|
|
|
height: 100%; */
|
2023-03-29 14:38:43 +08:00
|
|
|
vertical-align: -0.15em;
|
|
|
|
fill: currentColor;
|
|
|
|
overflow: hidden;
|
|
|
|
}
|
2023-03-28 18:04:49 +08:00
|
|
|
</style>
|