title: Taro.getSelectedTextRange(option)
sidebar_label: getSelectedTextRange
Obtains the cursor position of the input box after the focus of input, textarea, etc. Note: This API works only when it is called during the focus process.
Reference
Type
(option?: Option) => Promise<SuccessCallbackResult>
Parameters
Option
Property |
Type |
Required |
Description |
complete |
(res: CallbackResult) => void |
No |
The callback function used when the API call completed (always executed whether the call succeeds or fails) |
fail |
(res: CallbackResult) => void |
No |
The callback function for a failed API call |
success |
(res: CallbackResult) => void |
No |
The callback function for a successful API call |
SuccessCallbackResult
Property |
Type |
Description |
end |
number |
End position of the cursor in the input box |
start |
number |
Start position of the cursor in the input box |
errMsg |
string |
call result |
Sample Code
Taro.getSelectedTextRange({
complete: res => {
console.log('getSelectedTextRange res', res.start, res.end)
}
})
API Support
API |
WeChat Mini-Program |
H5 |
React Native |
Taro.getSelectedTextRange |
✔️ |
|
|