uniapp,h5

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <template>
  2. <view class="tools">
  3. <button class="tool-btn" @click="showEmojiPicker">
  4. <image src="/static/emoji.png" alt="Emoji" />
  5. </button>
  6. <button class="tool-btn" @click="showPlusMenu">
  7. <image src="/static/plus.png" alt="More" />
  8. </button>
  9. <EmojiPicker v-if="showEmoji" @emoji-selected="insertEmoji" />
  10. </view>
  11. </template>
  12. <script>
  13. import EmojiPicker from './EmojiPicker.vue';
  14. export default {
  15. name: 'Tools',
  16. components: {
  17. EmojiPicker,
  18. },
  19. data() {
  20. return {
  21. showEmoji: false,
  22. };
  23. },
  24. methods: {
  25. showEmojiPicker() {
  26. this.showEmoji = true;
  27. // 通知父组件
  28. // this.$emit('emoji-picker-shown');
  29. },
  30. showPlusMenu() {
  31. // ...
  32. },
  33. insertEmoji(emoji) {
  34. // 插入emoji到文本框或消息中
  35. // 例如,你可能需要调用一个方法来处理插入emoji
  36. console.log('Selected emoji:', emoji);
  37. this.showEmoji = false;
  38. },
  39. },
  40. };
  41. </script>
  42. <style scoped>
  43. .tools {
  44. display: flex;
  45. align-items: center;
  46. justify-content: center;
  47. gap: 10px;
  48. }
  49. .tool-btn {
  50. width: 40px;
  51. height: 40px;
  52. border: none;
  53. background: none;
  54. cursor: pointer;
  55. }
  56. .emoji-picker {
  57. position: absolute;
  58. bottom: 50px;
  59. left: 50%;
  60. transform: translateX(-50%);
  61. z-index: 100;
  62. }
  63. </style>