• 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>
  • 相关阅读:
    java中Annotation注解的定义与使用
    ABC184 D——F && 一道LC好题
    YZYのPython 作业~
    杂谈(11.13——lca && mst)
    树状数组(BIT)—— 一篇就够了
    Codeforces Round #673 (Div. 2)[A-E]
    Codeforces Round #674 (Div. 3)
    Educational Codeforces Round 95 (Rated for Div. 2) [A -- E]
    LEETCODE 第 205 场周赛
    Codeforces Round #662 (Div. 2)
  • 原文地址:https://www.cnblogs.com/tufei7/p/15523019.html
Copyright © 2020-2023  润新知