emoji 的使用方法
Sonder
2022-11-21
721字
2分钟
浏览 (1.1k)
![微信图片_20221121150404 1.png](https://s2.loli.net/2022/11/21/w19P2IbvrnlsUMT.png)
<template>
<div>
<div class='iconList'>
<span v-for='(item,index) in emojiList' :key='index' @click='addIcon(item)' class='smile'>{{item}}</span>
</div>
<textarea v-model="content"></textarea>
</div>
</template>
<script>
// npm install emoji
// "emoji": "^0.3.2",
import emoji from 'emoji'
export default {
data() {
return {
emojiListAll:Object.keys(emoji.EMOJI_MAP),
emojiList:Object.keys(emoji.EMOJI_MAP).slice(191,213).concat(Object.keys(emoji.EMOJI_MAP).slice(215,239)),
content: "",
}
},
methods: {
addIcon(icon){
this.content += icon;
},
}
}
</script>