该 API 使用方法为 wx.updateKeyboard(Object object)
属性 | 类型 | 默认值 | 必填 | 说明 |
value | string | - | 是 | 键盘输入框的当前值 |
success | function | - | 否 | 接口调用成功的回调函数 |
fail | function | - | 否 | 接口调用失败的回调函数 |
complete | function | - | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
该 API 使用方法为 wx.showKeyboard(Object object)
属性 | 类型 | 默认值 | 必填 | 说明 |
defaultValue | string | - | 是 | 键盘输入框显示的默认值 |
maxLength | number | - | 是 | 键盘中文本的最大长度 |
multiple | boolean | - | 是 | 是否为多行输入 |
confirmHold | boolean | - | 是 | 当点击完成时键盘是否保持显示 |
confirmType | string | - | 是 | 键盘右下角 confirm 按钮的类型,只影响按钮的文本内容 |
type | string | text | 否 | 键盘类型 |
success | function | - | 否 | 接口调用成功的回调函数 |
fail | function | - | 否 | 接口调用失败的回调函数 |
complete | function | - | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
合法值 | 说明 |
done | 完成 |
next | 下一个 |
search | 搜索 |
go | 前往 |
send | 发送 |
合法值 | 说明 |
text | 文本输入键盘 |
number | 数字输入键盘 |
digit | 带小数点的数字键盘 |
该 API 使用方法为 wx.onKeyboardInput(function listener)
属性 | 类型 | 说明 |
value | string | 键盘输入的当前值 |
该 API 使用方法为 wx.onKeyboardHeightChange(function listener)
属性 | 类型 | 说明 |
height | number | 键盘高度 |
wx.onKeyboardHeightChange(res => {console.log(res.height)})
该 API 使用方法为 wx.onKeyboardConfirm(function listener)
属性 | 类型 | 说明 |
value | string | 键盘输入的当前值 |
该 API 使用方法为 wx.onKeyboardComplete(function listener)
属性 | 类型 | 说明 |
value | string | 键盘输入的当前值 |
该 API 使用方法为 wx.offKeyboardInput(function listener)
const listener = function (res) { console.log(res) }wx.onKeyboardInput(listener)wx.offKeyboardInput(listener) // 需传入与监听时同一个的函数对象
该 API 使用方法为 wx.offKeyboardHeightChange(function listener)
const listener = function (res) { console.log(res) }wx.onKeyboardHeightChange(listener)wx.offKeyboardHeightChange(listener) // 需传入与监听时同一个的函数对象
该 API 使用方法为 wx.offKeyboardConfirm(function listener)
const listener = function (res) { console.log(res) }wx.onKeyboardConfirm(listener)wx.offKeyboardConfirm(listener) // 需传入与监听时同一个的函数对象
该 API 使用方法为 wx.offKeyboardComplete(function listener)
const listener = function (res) { console.log(res) }wx.onKeyboardComplete(listener)wx.offKeyboardComplete(listener) // 需传入与监听时同一个的函数对象
该 API 使用方法为 wx.hideKeyboard(Object object)
属性 | 类型 | 默认值 | 必填 | 说明 |
success | function | - | 否 | 接口调用成功的回调函数 |
fail | function | - | 否 | 接口调用失败的回调函数 |
complete | function | - | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
wx.hideKeyboard({complete: res => {console.log('hideKeyboard res', res)}})
文档反馈