支付宝小程序API 键盘
my.hideKeyboard
简介
my.hideKeyboard 是隐藏键盘的 API。
扫码体验
效果示例
示例代码
// 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();
}
},
});