uniapp - textarea 最大输入值在表情字符情况下限制不精准

197 阅读1分钟
通过...publishValue展开字符串可以区分表情字符
<view><text>{{[...publishValue].length }}/200</text></view>

watch{
    publishValue(n){
      if(n.length>=200){
        setTimeout(() => {
          let copy = this.publishValue
          let arr =  [...copy]
          arr.splice(200,arr.length-1)
          this.publishValue = arr.join('')
        })
      }
    }
}