Emotion.vue 751 Bytes
<template>
  <div class="ly-emotion">
    <slot></slot>
  </div>
</template>

<script>
import emoji from '@/utils/emo'
export default {
  name: 'ly-emotion',
  mounted() {
    const name = this.$el.innerHTML
    const list = emoji.flat(Infinity)
    let index = parseInt(list.indexOf(name)) + 1
    if (index < 10) {
      index = '00' + index
    } else if (index >= 10 && index < 100) {
      index = '0' + index
    }
    let imgHTML = `<img src="https://img01.glsx.com.cn/weapp/resource/saas/scrm/emoji/${index}.png">`
    this.$nextTick(() => {
      this.$el.innerHTML = imgHTML
    })
  }
}
</script>
<style scoped>
.ly-emotion {
  display: inline-block;
}
.ly-static-emotion {
  width: 24px;
  height: 24px;
  display: inline-block;
}
</style>