我有2个输入,当用户按Enter键时,希望切换焦点从第一个到第二个.
我尝试将jQuery与Vue混合,因为我找不到任何功能可以专注于Vue文档中的某些内容:
我尝试将jQuery与Vue混合,因为我找不到任何功能可以专注于Vue文档中的某些内容:
<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-on:keyup.enter="$event.target.nextElementSibling.focus()