Autofocus processing was blocked because a document already has a focused element.
场景:
因为页面有多个el-input
解决办法:
我是这样做的:
<el-input
v-else
v-model="item.sentence"
:ref=" 'input'+ item.id "
placeholder="请输入内容"
autosize
@click.native="changeContentData(item)"
@blur="item.ifInput=false"
@change="saveChangeSingleContentChecked(item)"
></el-input>
changeContentData(data) {
console.log('里面输入框被点击了')
console.log(data)
console.log(data.sentence)
let id = 'input' + data.id
console.log(this.$refs[id])
this.$refs[id][0].focus()
},
温馨提示:
这里的
this.$refs[id][0].focus()数组需要选中第0个索引才行
其他办法:
ElementUI的 input 的属性 autofocus(自动获取焦点) 失效_一方湖泊-CSDN博客_element input 自动获取焦点