亚洲免费在线观看_av网站免费观看_亚洲视频中文字幕_日本视频在线_香蕉一区二区_国产精品中文_这里只有精品久久_欧美一区二区三区不卡_日本高清在线观看_国产精品免费一区二区三区都可以_欧美黄色大片视频_自拍偷拍第1页_亚洲啪av永久无码精品放毛片_三级免费观看_日日狠狠_波多野结衣绝顶大高潮_国语一级片_亚洲丁香婷婷

027-81331413

微信小程序input怎么禁止輸入漢字

發布時間:2020-10-30 瀏覽:3838

最近在開發中遇到的一些坑點

  1. 表單組件(input)如何阻止冒泡

  2. 在容器(fixed)中的input如何彈出鍵盤

阻止input冒泡

  • <view bind:tap="onTap" class="container">

  • <input bindinput="onBindInput" type="text"/>

  • </view>


上例中input操作會冒泡到container,導致

  • onTap

響應執行

修正

  • <view bind:tap="onTap" class="container">

  • <input bindinput="onBindInput" type="text" catch:tap="empty"/>

  • </view>


冒泡的問題是由input的tap事件導致,因此定義一個empty的空方法,使它響應input的catch:tap,來達到阻止input的冒泡的作用

在容器(fixed)中的input如何彈出鍵盤

  • <view class="container" style="position: fixed; bottom: 0">

  • <input bindinput="onBindInput" type="text"/>

  • </view>


container組件在屏幕底部出現,點擊Input組件時,彈出的鍵盤會遮蓋input輸入框

修正

  • <view class="container" style="position: fixed; bottom: 0; {{mystyle}}">

  • <input bindinput="onBindInput" bindkeyboardheightchange="onkeybord" type="text"/>

  • </view>


Page({data: {mystyle: '',},onkeybord(e){let detail = e.detaillet kbHeight = detail.heightlet tool = Pager.getElementsById('reminder-tool')if (kbHeight === 0) {this.setData({mystyle: ' ' })}if (kbHeight && kbHeight > 0) {this.setData({mystyle: `bottom: ${kbHeight-40}px;` })}}})