zoukankan      html  css  js  c++  java
  • textarea 安卓 文本框内一直按“删除键”删除,会卡

    bug情况:

    https://aliossdl3.tower.im/652017/55a3f503c2538c8c7df9e7a084368d3f?Expires=1636338453&OSSAccessKeyId=LTAI4FzdzJ63WYH36wjrvT56&Signature=%2F4sdZKGdG8e690IPP%2Ba%2BelA1Tbc%3D&response-content-disposition=inline%3Bfilename%3D%22tmp_3559dc555c289f259bbce1992609df370e5d137598899f6f.mp4%22&response-content-type=video%2Fmp4

    可以看到,长按删除按钮,文本框在闪烁

    原因是

    textInputAction 方法里面频繁调用  setData,页面会重复渲染
    textInputAction: function (e) {
        var text = e.detail.value;
        var textLen = util.fnGetCpmisWords(text)
    
        var submitBtnActive = false
        if (this.data.type == 1 && textLen > 0) {
          submitBtnActive = true
        } else if (this.data.type == 2 && textLen > 0 && this.data.customTitle.length > 0) {
          submitBtnActive = true
        }
        // this.data.inputText = text
        this.setData({
          currentTextLength: textLen,
          inputText: text,
          sbActiveState: submitBtnActive,
          submitBtnText: text == this.data.tempRecogText ? '请编辑识别后的文本再提交' :'提交作文'
        })
      },

    改成    this.data.inputText = text, 别在setData里面更新inputText    就好了:

    textInputAction: function (e) {
        var text = e.detail.value;
        var textLen = util.fnGetCpmisWords(text)
    
        var submitBtnActive = false
        if (this.data.type == 1 && textLen > 0) {
          submitBtnActive = true
        } else if (this.data.type == 2 && textLen > 0 && this.data.customTitle.length > 0) {
          submitBtnActive = true
        }
        this.data.inputText = text
        this.setData({
          currentTextLength: textLen,
          // inputText: text,
          sbActiveState: submitBtnActive,
          submitBtnText: text == this.data.tempRecogText ? '请编辑识别后的文本再提交' :'提交作文'
        })
      },

     补充wxml:

    <textarea class='mTextArea' auto-height='{{true}}' maxlength='-1' value='{{inputText}}' bindinput='textInputAction'
          placeholder="{{sData.my_writing.hint}}" placeholder-class="tiClass" hidden="{{showSuccessCover}}"
          cursor-spacing='90'></textarea>
  • 相关阅读:
    redis运维的一些知识点
    nginx 实现Web应用程序的负载均衡
    JQuery中常用方法备忘
    高效程序猿之 VS2010快速生成代码模板
    C# var 隐式类型 var 用法 特点
    HTML之打开/另存为/打印/刷新/查看原文件等按钮的代码
    js函数大全(2)
    js常用函数大全107个
    js键盘键值大全
    js键盘键值大全
  • 原文地址:https://www.cnblogs.com/tufei7/p/15523019.html
Copyright © 2011-2022 走看看