跳到正文

EmojiPicker 表情选择器 ​

表情与表情包选择器,支持内置 Emoji 分类与自定义表情包(Sticker)数据。

使用方式 ​

组件以 EmEmojiPicker 为名导出,全局注册后可直接使用:

vue
<script setup lang="ts">
import { ref } from 'vue'

const show = ref(false)

function onSelect(emoji: string) {
  console.log(emoji)
}
</script>

<template>
  <em-button @click="show = true">选择表情</em-button>
  <em-emoji-picker v-model:show="show" @select="onSelect" />
</template>

基础用法 ​

表情包 ​

API ​

EmojiPicker API ​

Props ​

属性类型默认值说明
showboolean—是否显示面板,内部按 v-if 渲染;关闭时通过 update:show 通知父组件 / Whether to show the picker
stickerPacksEmojiStickerPack[]() => []表情包(sticker pack)列表,默认 [] 不展示表情包 tab / Sticker packs to show as extra tabs
closeOnSelectbooleanfalse选择 emoji / sticker 后自动关闭,默认 false
recentbooleantrue是否启用「常用」最近使用区(置于表情视图顶部),默认 true;关闭后不展示常用区也不再记录 / Whether to enable the recent-emoji section at the top of the emoji view, default true
recentCountnumber5常用列表长度(保留最近使用个数),默认 5 / Number of recently-used emojis kept, default 5
tabsPositionEmojiTabsPosition'bottom'tab 位置:顶部/底部/左侧/右侧,默认 'bottom' / Tabs position: top/bottom/left/right, default 'bottom'
stickerHoverbooleantruesticker 悬停时切换展示 gif(需提供 thumbUrl 预览图),默认 true / Swap to the gif on hover when thumbUrl is present, default true
emojiIconstring—「Emoji」视图 tab 预览小图 URL(可选,展示图片;不设时显示 😀 字形)/ Optional icon for the "Emoji" view tab, shown as an image instead of the default 😀 glyph

Events ​

事件名参数说明
update:showvalue: boolean面板显隐状态变化时触发(关闭携带 false),用于 v-model:show 同步 / Emitted when visibility changes
selectemoji: string点击 emoji 时触发,负载为选中的 emoji 字符 / Emitted when an emoji is picked
select-stickersticker: EmojiStickerItem, packId: string点击表情包中的 sticker 时触发,负载为 sticker 项与其所属 pack 的 id / Emitted when a sticker is picked