<template>
  <!-- <span class="dm-text__wrap ellipsis-l2 inline-block" v-html="item.content"></span> -->
  <pre class="inline-block">
    <span v-html="item.content"></span>
  </pre>
</template>
<script>
import options from '../assets/options.js';
export default {
  name: 'item-text',
  props: {
    item: {
      type: Object,
      default() {
        return {};
      }
    },
    isSupportVar: {
      type: Boolean,
      default: false
    }
  },
  computed: {
    transfContent() {
      // 替换{数字}为文本
      // console.log(this.item);
      let val = this.item.content;
      if (this.isSupportVar) {
        val = val.replace(/\{(?:[1-9]|(1[0-9])?|2[0-8])\}/g, (...argument) => {
          let str = '';
          let arg = argument[0];
          console.log(arg);
          options.map(v => {
            if (v.number === arg) {
              str = v.name;
            }
          });
          return str;
        });
      }
      if (this.item.urlType === 2) {
        val = val.replace(/\<.*\>(.*)\<.*\>/g, (...argument) => {
          let str = '';
          let arg = argument[0];
          str = '<i class="iconfont icon-xiaochengxu blue"></i>' + arg;
          console.log(arg);
          return str;
        });
      }
      return val;
    }
  }
};
</script>
