element-ui
监听键盘事件需要加native
,例如el-input
上监听enter
键,需要这么写:
<el-input
placeholder="请输入"
v-model="select_word1"
clearable
:style="'width:190px'"
@keyup.enter.native="getData(1)"
>
</el-input>
因为el-input
组件对input
进行过封装,在input
外层套了一个div
:
![](https://img.haomeiwen.com/i1976589/425d74b6da77473f.png)
官网给在根元素上监听原生事件提供的解决方案是:加
.native
修饰符。![](https://img.haomeiwen.com/i1976589/532e180d00a2d70c.png)
网友评论