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>
  • 相关阅读:
    依赖注入
    ToDictionary() and ToList()
    Middleware详解
    仓储层的搭建
    Controller和View的交互
    Configuration配置信息管理
    开发工具
    60分钟Python快速学习(转)
    oracle PL/SQL(procedure language/SQL)程序设计之函数+过程+包(转)
    ssh无密码登陆(转)
  • 原文地址:https://www.cnblogs.com/tufei7/p/15523019.html
Copyright © 2011-2022 走看看