From 87f9a68b23df34dc85a7a246dcaff126ee72ad1b Mon Sep 17 00:00:00 2001 From: qiang Date: Thu, 27 Aug 2020 17:02:24 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20=E5=A2=9E=E5=8A=A0=20uni.getSelectedTex?= =?UTF-8?q?tRange=20=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/api/key.md | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/docs/api/key.md b/docs/api/key.md index baebe2cfa..0d11eff86 100644 --- a/docs/api/key.md +++ b/docs/api/key.md @@ -34,3 +34,38 @@ uni.onKeyboardHeightChange(res => { console.log(res.height) }) ``` + +#### uni.getSelectedTextRange(OBJECT) + +在input、textarea等focus之后,获取输入框的光标位置。注意:只有在focus的时候调用此接口才有效。 + +**平台差异说明** + +|App|H5|微信小程序|支付宝小程序|百度小程序|字节跳动小程序|QQ小程序| +|:-:|:-:|:-:|:-:|:-:|:-:|:-:| +|HBuilderX 2.8.10+|HBuilderX 2.8.10+|基础库 2.7.0+|x|x|x|x| + +**OBJECT 参数说明:** + +| 参数名 | 类型 | 默认值 | 必填 | 说明 | +| --- | --- | --- | --- | --- | +| success | Function | | 否 | 接口调用成功的回调函数 | +| fail | Function | | 否 | 接口调用失败的回调函数 | +| complete | Function | | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | + +**success 返回参数说明:** + +| 属性 | 类型 | 说明 | +| --- | --- | --- | +| start | Number | 输入框光标起始位置 | +| end | Number | 输入框光标结束位置 | + +**示例代码** + +```js +uni.getSelectedTextRange({ + success: res => { + console.log('getSelectedTextRange res', res.start, res.end) + } +}) +``` -- GitLab