1,页面中有一个Input框和一个按钮,在安卓系统内没问题,在IOS上需要点击2次才能触发click事件。第1次收起键盘,第2次触发click

//主要代码
  <div class="inputBox">
        <div
          class="textarea"
          placeholder="说点什么吧~"
          contenteditable="true"
          id="testarea"
          @input="onTextareaInput"
          @focus="focus"
          @blur="blur"
          @keydown="keyDown"
        ></div>
        <van-button v-show="msg != ''" type="primary" size="small" @touchstart="sendMsg" >发送</van-button>

image.png

解决方法:

把click改成touchstart即可:
<van-button v-show="msg != ''" type="primary" size="small" @touchstart="sendMsg" >发送</van-button>

但是现在还有另外一个问题,就是发送后,键盘不自动收回。。
原因:向下滚动,发现input没有自动失去焦点。
image.png

解决方法:

让input主动失去焦点即可

 let textarea = document.getElementById("textarea");
      textarea.blur();

Kason
209 声望6 粉丝