emotionWords.vue 1.18 KB
<template>
  <div>
    <div class="emotion-box" :style="{ height: height + 'px' }">
      <div class="emotion-box-line" v-for="(line, i) in list" :key="i">
        <emotion class="emotion-item" v-for="(item, i) in line" :key="i" @click.native="clickHandler(item)">{{ item }}</emotion>
      </div>
    </div>
  </div>
</template>

<script>
import emoji from '@/utils/emo'
import Emotion from './Emotion'
export default {
  props: {
    height: {
      type: Number,
      default: 200
    }
  },
  data() {
    return {
      list: emoji
    }
  },
  methods: {
    clickHandler(i) {
      let emotion = `${i}`
      this.$emit('emotion', emotion)
    }
  },
  components: {
    Emotion
  }
}
</script>
<style scoped lang="scss">
.emotion-box {
  z-index: 2004;
  background-color: #fff;
  border-radius: 2px;
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.15);
  width: 300px;
  box-sizing: border-box;
  padding: 5px;
  overflow: hidden;
  overflow-y: auto;
}
.emotion-box-line {
  display: flex;
}
.emotion-item {
  flex: 1;
  text-align: center;
  cursor: pointer;
  /deep/ {
    img {
      width: 24px;
      -webkit-user-select: none;
      cursor: default;
      pointer-events: none;
    }
  }
}
</style>