emoji.vue 975 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <template>
  2. <div class="emoji-box flex-start">
  3. <div v-for="(item, index) in emojiList" :key="index" class="emoji-item">
  4. <img :data-name="item.emojiName" class="emoji-img" :src="item.url" @click="handleEnterEmoji"></img>
  5. </div>
  6. </div>
  7. </template>
  8. <script>
  9. import { emojiName, emojiUrl, emojiMap } from '../../../src/util/emojiMap.js';
  10. export default {
  11. data() {
  12. return {
  13. emojiList: []
  14. };
  15. },
  16. components: {},
  17. props: {},
  18. beforeMount() {
  19. for (let i = 0; i < emojiName.length; i++) {
  20. this.emojiList.push({
  21. emojiName: emojiName[i],
  22. url: emojiUrl + emojiMap[emojiName[i]]
  23. });
  24. }
  25. },
  26. methods: {
  27. handleEnterEmoji(event) {
  28. this.$emit('enterEmoji', {
  29. detail: {
  30. message: event.currentTarget.dataset.name
  31. }
  32. });
  33. }
  34. }
  35. };
  36. </script>
  37. <style>
  38. .emoji-box{
  39. height: 200px;
  40. flex-wrap: wrap;
  41. transition: height .3s;
  42. overflow-y: scroll;
  43. }
  44. .emoji-item{
  45. width:8%;
  46. display: inline;
  47. margin: 1%;
  48. }
  49. .emoji-img{
  50. width:100%;
  51. }
  52. </style>