Provides APIs for controlling the soft keyboard in mPaaS mini programs, including hiding the keyboard programmatically.
my.hideKeyboard
Note
This API is only supported in mPaaS 10.1.32 and later versions.
Hides the soft keyboard.
Code example
// API-DEMO page/API/keyboard/keyboard.json
{
"defaultTitle": "Keyboard"
}
<!-- API-DEMO page/API/keyboard/keyboard.axml-->
<view class="page">
<view class="page-description">Input box</view>
<view class="page-section">
<view class="form-row">
<view class="form-row-label">Password keyboard</view>
<view class="form-row-content">
<input class="input" password type="text" onInput="bindHideKeyboard" placeholder="Input 123 to automatically hide the keyboard" />
</view>
</view>
<view class="form-row">
<view class="form-row-label">Numeric keyboard</view>
<view class="form-row-content">
<input class="input" type="digit" onInput="bindHideKeyboard" placeholder="Input 123 to automatically hide the keyboard" />
</view>
</view>
</view>
</view>
// API-DEMO page/API/keyboard/keyboard.js
Page({
bindHideKeyboard(e) {
if (e.detail.value === "123") {
// Hide the keyboard
my.hideKeyboard();
}
},
});
该文章对您有帮助吗?