DocIcon.vue 728 Bytes
<template>
    <svg :class="svgClass" aria-hidden="true">
        <use :xlink:href="'#' + iconName" />
    </svg>
</template>

<script>
export default {
    name: 'doc-icon',
    props: {
        type: String,
        className: String
    },
    computed: {
        iconName() {
            return `icon-${this.type}`
        },
        svgClass() {
            return this.className ? `svg-icon ${this.className}` : 'svg-icon'
        }
    }
}
</script>

<style lang="less" scoped>
.svg-icon {
    width: 1em;
    height: 1em;
    // vertical-align: text-bottom;
    vertical-align: -11%;
    // currentColor 当前的标签所继承的文字颜色
    fill: currentColor;
    overflow: hidden;
    outline: none;
}
</style>