需求描述:页面是table里面嵌入input,用户要求按回车去下一个input
之前由于用到elementUI的,用于改变许多类型,之后就自己用原生的input去实现
具体代码:
<input
type="number"
:ref="`ipt` + index"
:class="`ipt` + index"
v-model="pLitem.newPoint"
@keyup="limitPoint(pLitem)"
@keyup.enter="
enterCallback(index, qsItem.pointList.length)
"
:name="index"
:min="0"
/>
//js
enterCallback(index, Plength) {
if (index < Plength - 1) {
let bq = '.ipt' + `${index + 1}`
window.document.querySelector(bq).focus()
} else {
window.document.querySelector('.textarea').focus()
if (this.pContent != '') {
this.saveAnswer()
}
}
},