微信小程序输入框光标错乱问题

 会出现这个问题,一般是受到了滚动条的影响,所以,在获取焦点时,需要关闭页面滚动,失去焦点时,就开启滚动,例如页面里存在scroll-view组件

示例代码

wxml片段

<scroll-view class="m_scroll" style="height:100vh;" scroll-y="{{aFocus}}" scroll-with-animation>
</scroll-view>


<input type="text" class="i_l_input" placeholder="" bindfocus="handleFocus" bindblur="handleBlur" 
      adjust-position="{{false}}"
      maxlength="120"
      />    

 

js片段

  data: {
    aFocus: true
  },

  handleFocus(e){
      
    this.setData({
      aFocus:false
    })
  },
  handleBlur(){
    this.setData({
      aFocus:true
    })

  },

 

posted @ 2023-06-07 15:50  木人子韦一日尘  阅读(503)  评论(0编辑  收藏  举报