textarea焦点

发布于 6 年前作者 zengguiying9896 次浏览最后编辑 6 年前来自 ask

编辑textarea中的文本时,焦点自动跳到文本末尾

2 回复
longyong
longyong1 楼6 年前

可以设置cursor属性

qianglu
qianglu2 楼4 年前

<textarea class=“area”  cursor=“{{cursorIndex}}”

focus=“{{true}}” name=“content” selection-start=“{{cursorIndex}}”

selection-end=“{{cursorIndex}}” bindfocus=“bindfocus”

bindinput=“getTextareaValue” value=“{{content}}”

show-confirm-bar=“{{false}}” />

getTextareaValue(e) {

    let { value, cursor } = e.detail;

    this.content = value;

    this.cursorIndex = Number(cursor);

    console.info(‘cursorIndex’, this.cursorIndex, ‘typeof’, typeof this.cursorIndex, ‘content’, content);

    this.$apply();

},

不起作用呀???