search

Home  >  Q&A  >  body text

javascript - Use vue.js to monitor the enter event, but there is no response at all

<el-button slot="append" icon="search" @click="handSearch" @keyup.enter="handSearch"></el-button>
                
methods: {
            handSearch(){
                this.items.splice(0, this.items.length);
                this.$store.dispatch('findNewsPage', {key: this.input})
            }
        }
高洛峰高洛峰2788 days ago618

reply all(3)I'll reply

  • 天蓬老师

    天蓬老师2017-05-19 10:23:48

    First of all, the component does not have a built-in keyup event, so it should be @keyup.enter.native, but shouldn’t this event be written on the input component?

    reply
    0
  • 迷茫

    迷茫2017-05-19 10:23:48

    The buttons and input of the element component are unresponsive, but ordinary input and buttons are ok.

    reply
    0
  • 黄舟

    黄舟2017-05-19 10:23:48

    First go to the elementui documentation to see if there are custom events. If so, use the events provided by elementui.
    If not, use the .native modifier to pass the event to the subcomponent

    给组件绑定原生事件
    
    有时候,你可能想在某个组件的根元素上监听一个原生事件。可以使用 .native 修饰 v-on 。例如:
    <my-component v-on:click.native="doTheThing"></my-component>

    vue binds native events to components

    reply
    0
  • Cancelreply