45 lines
927 B
Vue
Raw Normal View History

2023-03-28 18:04:49 +08:00
<template>
<!-- <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>
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
},
svgClass() {
if (this.className) {
return 'svg-icon ' + this.className;
} else {
return 'svg-icon';
2023-03-28 18:04:49 +08:00
}
}
}
};
2023-03-28 18:04:49 +08:00
</script>
<style scoped>
.svg-icon {
/* width: 100%;
2023-03-28 18:04:49 +08:00
height: 100%; */
vertical-align: -0.15em;
fill: currentColor;
overflow: hidden;
}
2023-03-28 18:04:49 +08:00
</style>