easeChat模块demo发送表情案例
<div class="center-body ellipsis-1" v-html="fnType(lists.latestMessage.body.type,index)"></div>
<!-- 表情转换js -->
<script type="text/javascript" src="../script/emotion.js"></script>
fnType: function(types, index) {
//text:文本类型
//image:图片类型
//video:视频类型
//location:位置类型
//voice:语音类型
//file:文件类型
if (types == "text") {
复制代码
<!-- 文本消息 -->
<div class="chat-content" v-if="chats.body.type=='text'">
<div class="chat-arrow"></div>
<div class="body picbody" v-html="translateText(chats.body.text)"></div>
</div>
<!-- 表情转换js -->
<script type="text/javascript" src="../../script/emotion.js"></script>
//文本表情转化
translateText: function(text) {
if (text == '' || text == undefined) {
return;
}
msg = text;
var emotionObj = emotion;
var regx = /\[(.*?)\]/gm;
var translateMSg = text.replace(regx, function(math) {
var imgSrc = emotionObj[math];
if (!imgSrc) {
return math;
}
var img = '<img src="../../res/img/emotion/' + imgSrc + '.png" class="emotion">'
return img;
})
console.log(translateMSg)
return translateMSg;
}
复制代码

浙公网安备 33010602011771号