<template>
  <div class="co-rect" :class="[
      type ? type : '',
    forcesize ? forcesize : size ? size : (defaultsize ? defaultsize : ''),
    prefix ? prefix : '',
      {
        'bold': bold
      }
    ]">
    <i v-if="icon" :class="icon" v-html="iconSource"></i>
    <span><slot></slot></span>
  </div>
</template>

<script>
  export default {
    name: 'CoRect',
    props: {
      msg: String,
      size: String,
      prefix: String,
      type: String,
      bold: Boolean,
      img: String,
      icon: String
    },
    computed: {
      iconSource() {
        var dom = '';
        if (this.icon.match(RegExp(/.svg/))) {
          // console.log("暂不支持svg");
          dom += '<img src="' + this.icon + '" />';
        } else if (this.icon.match(RegExp(/.png|.jpg|.gif/))) {
          dom += '<img src="' + this.icon + '" />';
        }
        return dom;
      }
    }
  };
</script>
