Appearance
qin.hideKeyboard()
隐藏软键盘
隐藏已经显示的软键盘,如果软键盘没有显示则不做任何操作。
平台差异说明
| H5 | 微信小程序 | 小红书小程序 | 抖音小程序 | 快手小程序 |
|---|---|---|---|---|
| √ | √ | x | √ | √ |
qin.onKeyboardHeightChange(CALLBACK)
监听键盘高度变化
平台差异说明
| H5 | 微信小程序 | 小红书小程序 | 抖音小程序 | 快手小程序 |
|---|---|---|---|---|
| x | 基础库2.7+ | x | x | √ |
参数
function listener
键盘高度变化事件的监听函数
参数
Object res
| 参数 | 类型 | 说明 |
|---|---|---|
| height | Number | 键盘高度 |
示例代码
js
qin.onKeyboardHeightChange(theRes => {
console.log(theRes.height);
});qin.onKeyboardHeightChange(theRes => {
console.log(theRes.height);
});qin.offKeyboardHeightChange(CALLBACK)
取消监听键盘高度变化事件
平台差异说明
| H5 | 微信小程序 | 小红书小程序 | 抖音小程序 | 快手小程序 |
|---|---|---|---|---|
| x | 基础库2.9.2+ | x | x | x |
参数
function listener
onKeyboardHeightChange 传入的监听函数。不传此参数则移除所有监听函数。
示例代码
js
const theListener = (theRes) => { console.log(theRes); };
qin.onKeyboardHeightChange(theListener);
// 需传入与监听时同一个的函数对象
qin.offKeyboardHeightChange(theListener);const theListener = (theRes) => { console.log(theRes); };
qin.onKeyboardHeightChange(theListener);
// 需传入与监听时同一个的函数对象
qin.offKeyboardHeightChange(theListener);qin.getSelectedTextRange(OBJECT)
在 input 、 textarea 等 focus 之后,获取输入框的光标位置。注意:只有在 focus 的时候调用此接口才有效。目前仅支持 vue 页面。
平台差异说明
| H5 | 微信小程序 | 小红书小程序 | 抖音小程序 | 快手小程序 |
|---|---|---|---|---|
| √ | 基础库 2.7.0+ | x | x | √ |
OBJECT 参数说明:
| 参数名 | 类型 | 默认值 | 必填 | 说明 |
|---|---|---|---|---|
| success | Function | 否 | 接口调用成功的回调函数 | |
| fail | Function | 否 | 接口调用失败的回调函数 | |
| complete | Function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
success 返回参数说明:
| 属性 | 类型 | 说明 |
|---|---|---|
| start | Number | 输入框光标起始位置 |
| end | Number | 输入框光标结束位置 |
示例代码
js
qin.getSelectedTextRange({
success: theRes => {
console.log('getSelectedTextRange res', theRes.start, theRes.end);
},
});qin.getSelectedTextRange({
success: theRes => {
console.log('getSelectedTextRange res', theRes.start, theRes.end);
},
});