Vue-binding keyboard events to element-ui's input box does not take effect

Problem Description

Use the input component of elementui in vue to bind the carriage return event to take effect.

<el-input @keyup.enter='方法'></el-input>

problem causes

v-on或@If you use the listening event directly in vue , what you listen to is 由组件中使用$emit自定义的事件, for example, the following code.

子组件
...
this.$emit('test')
...

父组件
...
<子组件标签  @test='方法'/>
...

Solution

Use modifiers to tell vue whether .nativethis is triggered , such as the following listener .原生事件自定义事件element-ui的输入框回车事件

<el-input @keyup.enter.native='方法'></el-input>

Guess you like

Origin blog.csdn.net/qq_45458749/article/details/125455162