index.vue 883 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <template>
  2. <view class="emoji-box flex-start">
  3. <view v-for="(item, index) in emojiList" :key="index" class="emoji-item">
  4. <image :data-name="item.emojiName" class="emoji-img" :src="item.url" @tap="handleEnterEmoji"></image>
  5. </view>
  6. </view>
  7. </template>
  8. <script>
  9. import { emojiName, emojiUrl, emojiMap } from '../../../base/emojiMap';
  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. // this.setData({
  26. // emojiList: this.emojiList
  27. // });
  28. },
  29. methods: {
  30. handleEnterEmoji(event) {
  31. this.$emit('enterEmoji', {
  32. detail: {
  33. message: event.currentTarget.dataset.name
  34. }
  35. });
  36. }
  37. }
  38. };
  39. </script>
  40. <style>
  41. @import './index.css';
  42. </style>