怎么实现点击按钮,让光标聚焦到指定的输入框?

发布于 8 年前作者 daixiuying10075 次浏览最后编辑 8 年前来自 issues

1 回复
luolei
luolei1 楼5 年前
<input focus="{{focusId == 1}}" />
<input focus="{{focusId == 2}}" />
<input focus="{{focusId == 3}}" />
<button bindtap="onClick">按钮</button>

onClick() {
  if (...) {
    this.setData({
      focusId: 1
    })
  } else if ...
}