SelectionContext.setBaseAndExtent(string anchorNodeId, number anchorOffset, string focusNodeId, number focusOffset)

查看 llm.txt

基础库 3.16.2 开始支持,低版本需做兼容处理。

小程序插件:支持

功能描述

主动设置 selection 组件内部选区的起点与终点。节点 id 与偏移可由 selection 组件 selectionchange 事件返回的 firstNodeId/firstOffset、lastNodeId/lastOffset 得到。

参数

string anchorNodeId

选区起点所在节点的 id。

number anchorOffset

选区起点在节点内的偏移。

string focusNodeId

选区终点所在节点的 id。

number focusOffset

选区终点在节点内的偏移。