1.资料库

vue组件库,有多个emoji相关的组件,根据需要选择一个。

vue组件库地址:

Emoji - Vue.js Examples

我选择的是vue-twemoji-picker

vue组件地址:

A fast plug-n-play Twitter Emoji Picker for Vue

github地址:

GitHub - kevinfaveri/vue-twemoji-picker: Vue Twemoji Picker - A fast plug-n-play Twemoji Picker (+textarea for Twemoji rendering) for Vue. Support Unicode Emoji 13.0.

vue-twemoji-picker组件官网地址:

Vue Twemoji Picker

2.使用概述

2.1安装组件

npm install @kevinfaguiar/vue-twemoji-picker
// OR
yarn add @kevinfaguiar/vue-twemoji-picker

2.2引入使用

引入的{lang}要在本地定义语言包的种类。这个是官网给出的简单例子。

<template><twemoji-textarea :emojiData="emojiDataAll" :emojiGroups="emojiGroups" @enterKey="onEnterKey"></twemoji-textarea>
</template>
<script>import {TwemojiTextarea} from '@kevinfaguiar/vue-twemoji-picker';import EmojiAllData from '@kevinfaguiar/vue-twemoji-picker/emoji-data/{LANG}/emoji-all-groups.json';import EmojiGroups from '@kevinfaguiar/vue-twemoji-picker/emoji-data/emoji-groups.json';export default {name: 'App',components: {'twemoji-textarea': TwemojiTextarea},computed: {emojiDataAll() {return EmojiAllData;},emojiGroups() {return EmojiGroups;}},methods: {onEnterKey(e) {console.log("ClickedEnter", e);}}}
</script>

正式项目中使用,还需要一些事件和属性的定义,demo如下:

<template>
twemoji-textarea ref="twemoji"placeholder="请输入文本内容"initialContent='initialContent'@contentChanged="contentChanged":textareaDisabled="!canEdit":emojiPickerDisabled="!canEdit":emojiData="emojiDataAll" :emojiGroups="emojiGroups" @enterKey="onEnterKey"></twemoji-textarea></template>
<script>import {TwemojiTextarea} from '@kevinfaguiar/vue-twemoji-picker';import EmojiAllData from '@kevinfaguiar/vue-twemoji-picker/emoji-data/zh/emoji-all-groups.json';import EmojiGroups from '@kevinfaguiar/vue-twemoji-picker/emoji-data/emoji-groups.json';
xport default {name: 'App',data () {initialContent:'初始化值'},components: {'twemoji-textarea': TwemojiTextarea},computed: {emojiDataAll() {return EmojiAllData;},emojiGroups() {return EmojiGroups;}},methods: {onEnterKey(e) {console.log("ClickedEnter", e);},//输入框内容改变触发的事件,val返回最新数值contentChanged(val) {console.log(val)this.detailForm.momentContent = val},//清空内容clear(){this.$refs.twemoji.cleanText()},//给文本域赋值,例如接口返回数据赋值addText(){this.$refs.twemoji.addText('最新的数据显示')}}}
</script>

3.部分API,Props

3.1 initialContent

type:string

This prop indicates the initial value of the textarea.

定义文本域的初始值。

3.2 enableSendBtn

type:boolean

The value of this prop represents whether the send button is enabled.

是否显示发送按钮,

3.3 emojiPickerDisabled

type:boolean

The value of this prop represents whether the emoji picker is enabled.

表情选择器是否可编辑

3.4 textareaDisabled

type:boolean

The value of this prop represents whether the textarea is enabled.

文本域是否可以编辑

3.5 placeholder

type:string

Define the textarea placeholder.

文本域的输入提示

3.6 maxlength

type:number

Define the textarea maxlength. If set to null has no default maxlength. If set to any number the textarea will automatically expand itself to show a character count.

设置文本域的最大字符串。

4 API,event

4.1 contentChanged(content)

conten,string类型,文本域内容改变的时候触发,content字符串类型,返回最新的文本域数值。

4.2 enterKey(event)

按下回车键的时候触发

5 Ref Useful Methods

5.1 addText(content)

content参数,string类型。

This method adds a text to the textarea. The text parameter will then be sanitized and emojis Unicodes converted to emoji IMG arts from Twemoji.

将文本添加到文本区域,包括表情符号也正常显示。

5.2 cleanText()

This method cleans the textarea.

清空文本域内容

最后效果图:

Vue使用emoji表情包相关推荐

  1. vue 使用emoji表情包

    1.前端页面 vue <template><div class="test"><div v-show="show" :class= ...

  2. markdown中快速插入Emoji表情包语法速查表!!!

    markdown中快速插入Emoji表情包语法速查表!!!

  3. CSS雪碧图制作emoji表情包

    效果图: 原理:利用雪碧图,来实现emoji表情包,减少图片请求数. 表情包转换为文字 & 文字转换为表情包 维护两个对象来实现. 缺点:表情包大小由雪碧图中表情包大小控制,不能更改. htm ...

  4. Emoji-Chat emoji表情包发送及显示兼容web端、移动端

    Emoji-Chat emoji表情包发送及显示兼容web端.移动端 序言 在如今聊天表情包满天飞的当下,聊天过程中想发送个表情感慨一下情绪在所难免,当下我就遇到这么个需求,希望在web端聊天室中可以 ...

  5. js文本内去除emoji表情包

    利用正则匹配emoji表情包并且去除 let Arr=['emoji

  6. linux版微信 能发表情包的,仿微信在对话框文字中插入Emoji表情包

    场景 类似于微信聊天的一个对话框,要求可以使用EMOJI表情,对话框是一个div,通过改变contentEditable属性使得内容可以编辑. 问题 Emoji表情在页面中其实是GIF格式的IMG标签 ...

  7. 前端emojs_Emoji-Chat emoji表情包发送及显示兼容web端、移动端

    序言 在如今聊天表情包满天飞的当下,聊天过程中想发送个表情感慨一下情绪在所难免,当下我就遇到这么个需求,希望在web端聊天室中可以发送表情,还得在web端.微信H5.app端.微信公众号里均可以正常显 ...

  8. php文本框添加表情,仿微信在对话框文字中插入Emoji表情包

    场景 类似于微信聊天的一个对话框,要求可以使用EMOJI表情,对话框是一个div,通过改变contentEditable属性使得内容可以编辑. 问题 Emoji表情在页面中其实是GIF格式的IMG标签 ...

  9. 仿微信在对话框文字中插入Emoji表情包

    场景 类似于微信聊天的一个对话框,要求可以使用EMOJI表情,对话框是一个div,通过改变contentEditable属性使得内容可以编辑. 问题 Emoji表情在页面中其实是GIF格式的IMG标签 ...

  10. 基与Vue的emoji表情使用 --- emoji-vue的使用和bug修改

    介绍 最近的项目用到了表情包,咱们以前项目有用到emoji-vue.我就直接拿来用了.使用过程中真的一言难尽啊~~~~~ 先附上一张这个插件在Vue中使用的列子.可以清楚的看到一个比较重要的方法onI ...

最新文章

  1. 15 -Flask构建弹幕微电影网站-基于角色的访问控制
  2. 【262】pscp命令 实现windows与linux互传文件
  3. 金融贷款逾期的模型构建6——特征选择
  4. BugKuCTF 加密 ok
  5. springmvc执行流程(简述易懂)
  6. python之torchlight使用_为什么Python被誉为全世界最高效的编程语言?
  7. 什么是alpha测试_什么是ALPHA?
  8. 第13篇: Flowable-BPMN操作流程之流程进展查看之流程图
  9. 语言谓词函数isprime_G?del完备性定理 —— 一阶谓词逻辑演绎系统 Part II
  10. 一些学习笔记和工作布置
  11. 胡适:一个最低限度的国学书目
  12. 屏幕录像专家2018注册机怎么用?
  13. 推荐一个宝藏公众号,附大数据PPT合集下载
  14. JsBarcode 安装、使用、生成条形码的容器 及 参数配置options。 还存在的问题:条形码总体的宽度设置问题
  15. PYTHON对数值变量进行标准化,离散变量标签化
  16. IOS 企业级苹果开发者账号申请流程
  17. 图解NodeJS【基于事件、回调的单线程高性能服务器】原理
  18. 30分钟java桌球小游戏_30分钟完成桌球小游戏项目
  19. 雷柏V500机械键盘——重复按键故障原因之一
  20. 回溯问题一:地图涂色,四色定理证明

热门文章

  1. 秒杀系统设计的关键点思考
  2. pyltp依存句法分析_pyltp的简单使用
  3. 双叉积——拉格朗日公式证明
  4. matlab环境下图像分形维数的计算,MATLAB环境下图像分形维数的计算
  5. [置顶] 博客停止更新 我的大学数年
  6. 斗地主系列之牌型判断
  7. ERP原理:第一节 ERP的总体结构
  8. MindMaster Pro 7.3中文版 — 亿图思维导图
  9. 大数据分析案例:电力窃漏电用户自动识别
  10. 图像/视频无损放大,用一个工具就够了