小程序官方提供的表情库

184 阅读1分钟

小程序官方提供的表情库可以通过以下步骤在小程序中引入并使用:

  1. 在小程序工具中打开项目,进入app.json文件,在"pages"字段中添加"wxs"页面路径,例如:"pages/wxs/wxs"。
  2. 在项目中新建"wxs"文件夹,存放自定义表情相关的JS文件和图片。
  3. 在"wxs"页面中使用官方提供的表情组件,例如:
<emoji-group bind:select="onSelect"> </emoji-group>
  1. 在"wxs"页面的JS文件中实现"onSelect"函数,用来获取选择的表情信息,例如:
onSelect: function(e) {
  console.log(e.detail);
}
  1. 在"wxs"页面的JS文件中引入官方提供的表情组件库,例如:
var emoji = require('../../libs/emoji.js');
Page({
  data: {
    list: emoji.emoji_data
  },
  // ...
})
  1. 在"wxs"页面的WXML文件中使用官方表情组件库提供的表情标签,例如:
<view wx:for="{{list}}" wx:key="{{index}}">
  <emoji type="{{item.type}}" size="{{40}}" @click="onSelect" binderror="error">
    <image src="{{item.url}}" />
  </emoji>
</view>
  1. 这样就可以在小程序中使用官方提供的表情库了。