<template>
    <span
      class="el-bio-icon bio-font"
      :title="title"
      :style="{color: color, fontSize: size}"
      :class="iconName"
      :disabled="disabled"
      @click="onClick">
  </span>
</template>

<script>
export default {
  name: 'BioIcon',

  props: {
    name: {
      type: String,
      required: true
    },

    size: {
      type: String
    },

    color: {
      type: String
    },

    disabled: {
      type: Boolean,
      default: false
    },

    title: {
      type: String
    },

    prefix: {
      type: String,
      default: 'bio-icon__'
    }
  },

  computed: {
    iconName() {
      return this.prefix + this.name;
    }
  },

  methods: {
    onClick(e) {
      if (this.disabled) {
        if (e && e.preventDefault) {
          e.preventDefault();// 非IE浏览器
        } else { window.event.returnValue = false; } // IE浏览器
      } else {
        this.$emit('click');
      }
    }
  }
};
</script>
<style lang="scss" scoped>
@import 'font/iconfont.css';

</style>
