textarea焦点
发布于 4 年前 作者 zengguiying 9702 次浏览 来自 问答

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

2 回复

可以设置cursor属性

<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();

},

不起作用呀???

回到顶部