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

> 基础库 3.16.2 开始支持，低版本需做[兼容处理](1003706)。

> __小程序插件__：支持

## 功能描述

主动设置 [selection](https://developers.weixin.qq.com/miniprogram/dev/component/selection.html) 组件内部选区的起点与终点。节点 id 与偏移可由 [selection](https://developers.weixin.qq.com/miniprogram/dev/component/selection.html) 组件 selectionchange 事件返回的 firstNodeId/firstOffset、lastNodeId/lastOffset 得到。

## 参数

### string anchorNodeId

选区起点所在节点的 id。

### number anchorOffset

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

### string focusNodeId

选区终点所在节点的 id。

### number focusOffset

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