小程序显示表情
function renderEmotion(content) {let emotionList = ['微笑', '撇嘴', '色', '發(fā)呆', '得意', '流淚', '害羞', '閉嘴', '睡', '大哭', '尷尬', '發(fā)怒', '調(diào)皮', '呲牙', '驚訝', '難過', '酷', '冷汗', '抓狂', '吐', '偷笑', '可愛', '白眼', '傲慢', '饑餓', '困', '驚恐', '流汗', '憨笑', '大兵', '奮斗', '咒罵', '疑問', '噓', '暈', '折磨', '衰', '骷髏', '敲打', '再見', '擦汗', '摳鼻', '鼓掌', '糗大了', '壞笑', '左哼哼', '右哼哼', '哈欠', '鄙視', '委屈', '快哭了', '陰險(xiǎn)', '親親', '嚇', '可憐', '菜刀', '西瓜', '啤酒', '籃球', '乒乓', '咖啡', '飯', '豬頭', '玫瑰', '凋謝', '示愛', '愛心', '心碎', '蛋糕', '閃電', '炸彈', '刀', '足球', '瓢蟲', '便便', '月亮', '太陽(yáng)', '禮物', '擁抱', '強(qiáng)', '弱', '握手', '勝利', '抱拳', '勾引', '拳頭', '差勁', '愛你', 'NO', 'OK', '愛情', '飛吻', '跳跳', '發(fā)抖', '慪火', '轉(zhuǎn)圈', '磕頭', '回頭', '跳繩', '揮手', '激動(dòng)', '街舞', '獻(xiàn)吻', '左太極', '右太極'];return content.replace(/\[[\u4E00-\u9FA5]{1,3}\]/gi, (res) => {let word = res.replace(/\[|\]/gi,'');let index = emotionList.indexOf(word);// const src = require(`../images/emotion/${index}.gif`);return `<img src='/images/emotion/${index}.gif' style='width: 30rpx;vertical-align:middle;'/>`;})
};
module.exports = {renderEmotion:renderEmotion
}
<template is="dynamic" data="{{model: item.data, objectId: item.data.id,content:item.data.content}}" />引入模板展示富文本:
總結(jié)
- 上一篇: 设计模式 外观模式 一键电影模式
- 下一篇: Windows 隐藏小电影?