<template>
    <i class="iconfont" :class="[type ? 'icon-' + type : '']" :style="styleObject"></i>
</template>

<script function>
export default {
    name: 'lv-icon',
    data () {
        return {
            styleObject: {}
        }
    },
    props: {
        type: {
            type: String,
            default: ''
        },
        color: {
            type: String,
            default: ''
        },
        fontSize: {
            type: Number,
            default: 12
        },
        fontUnit: {
            type: String,
            default: 'px'
        }
    },
    watch: {
        fontSize(newSize) {
            if (newSize) this.$set(this.styleObject, 'font-size', this.fontSize + this.fontUnit);
        },
        color(newColor) {
            if (newColor) this.$set(this.styleObject, 'color', this.color);
        }
    },
    mounted() {
        if (this.color) {
            this.$set(this.styleObject, 'color', this.color);
        }
        if (this.fontSize) {
            this.$set(this.styleObject, 'font-size', this.fontSize + this.fontUnit);
        }
    }
}
</script>

<style lang="less" scope>
@font-face {
    font-family: "iconfont"; /* Project id 2760070 */
    src: url('../../assets/font/iconfont.woff2?t=1629537928872') format('woff2'),
         url('../../assets/font/iconfont.woff?t=1629537928872') format('woff'),
         url('../../assets/font/iconfont.ttf?t=1629537928872') format('truetype');
}
.iconfont {
    font-family: "iconfont" !important;
    font-size: 16px;
    font-style: normal;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
.icon-add:before {
    content: "\e600";
}
.icon-addRound:before {
    content: "\e608";
}
.icon-wechat:before {
    content: "\e609";
}
.icon-friend:before {
    content: "\e60b";
}
.icon-share:before {
  content: "\e610";
}
.icon-thumbs:before {
  content: "\e611";
}
.icon-arrow:before {
  content: "\e613";
}
.icon-message:before {
  content: "\e612";
}

</style>