glTextarea.js 905 Bytes
// components/glTextarea/glTextarea.js
import { haveEmoji, replaceEmoji } from '../../utils/util.js'
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    maxlength:{
      type:Number,
      value:-1
    },
    placeholder:String,
    showWordLimit: Boolean,
    disabled:Boolean,
    value:String
  },

  /**
   * 组件的初始数据
   */
  data: {
    edit:true,
    value:null
  },

  /**
   * 组件的方法列表
   */
  methods: {
    /**
   * 打开文本编辑器
   */
    openTextarea() {
      if (this.data.disabled) return
      this.setData({
        edit: false,
        textareaFocus: true
      })
    },
    textareaBlur(e) {
      let value = e.detail.value
      if (haveEmoji(value)) value = replaceEmoji(value)
      this.setData({
        value: value,
        edit: true
      })
      this.triggerEvent('input', {
        value: value
      })
    },
  }
})