• 下载
  • 社区

my.hideKeyboard

隐藏键盘。


扫码体验

键盘.jpeg


效果示例


键盘5-5.png


示例代码


// API-DEMO page/API/keyboard/keyboard.json
{
  "defaultTitle": "键盘"
}


<!-- API-DEMO page/API/keyboard/keyboard.axml-->
<view class="page">
  <view class="page-description">输入框</view>
  <view class="page-section">
    <view class="form-row">
      <view class="form-row-label">密码键盘</view>
      <view class="form-row-content">
        <input class="input" password type="text" onInput="bindHideKeyboard" placeholder="输入 123 自动收起键盘" />
      </view>
    </view>

    <view class="form-row">
      <view class="form-row-label">数字键盘</view>
      <view class="form-row-content">
        <input class="input" type="digit" onInput="bindHideKeyboard" placeholder="输入 123 自动收起键盘" />
      </view>
    </view>
  </view>
</view>


// API-DEMO page/API/keyboard/keyboard.js
Page({
  bindHideKeyboard(e) {
    if (e.detail.value === "123") {
      // 收起键盘
      my.hideKeyboard();
    }
  },
});