收藏
回答

textarea焦点

框架类型 API/组件名称 终端类型 操作系统 微信版本 基础库版本
小程序 textarea 客户端 6.6.1 1.9.9
编辑textarea中的文本时,焦点自动跳到文本末尾
回答关注问题邀请回答
收藏

2 个回答

  • 黄思程
    黄思程
    2018-03-16

    可以设置cursor属性

    2018-03-16
    有用
    回复
  • 10个肉包子
    10个肉包子
    2018-03-27

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

    },

    不起作用呀???


    2018-03-27
    有用
    回复
登录 后发表内容