我有2個輸入,當用戶按Enter鍵時,需要從第一個焦點到第二個焦點。 我試着搭配的jQuery與Vue公司becouse我找不到任何功能,專注在某件事Vue的文檔中:Vue JS將焦點放在輸入的下一個輸入
<input v-on:keyup.enter="$(':focus').next('input').focus()"
...>
<input ...>
但在進入我看到控制檯錯誤:
build.js:11079 [Vue warn]: Property or method "$" is not defined on the instance but referenced during render. Make sure to declare reactive data properties in the data option. (found in anonymous component - use the "name" option for better debugging messages.)warn @ build.js:11079has @ build.js:9011keyup @ build.js:15333(anonymous function) @ build.js:10111
build.js:15333 Uncaught TypeError: $ is not a function
我不知道答案,但請儘量在V-這個':keyup.enter = 「this.nextSibling.focus()」' – Robiseb
感謝您的幫助!結果是'build.js:15333 Uncaught TypeError:無法讀取未定義的屬性'焦點' – user3479125
您的第二個輸入有一個ID? ''。嘗試添加一個並更改此行'v-on:keyup.enter =「document.getElementById('XX')。focus()」' – Robiseb