N
N
Nikolai Chuprik2020-02-23 20:58:57
Vue.js
Nikolai Chuprik, 2020-02-23 20:58:57

How to listen to Enter from the keyboard in a modal window (component)?

There is a component - a modal window with a notification. In the message box and the "OK" button.

Vue.component( 'alert', {
  template: '
    <div class = "alert">
      <slot>
        <div class = "modal-content"></div>
      </slot>
      <button @click="close"> ОК </button>
    </div>
  ',

  methods:	{
    close: function ( e )	{
      e.stopPropagation();
      this.$emit( 'close' );
    }
} )


The window is closed by clicking on "OK". But I want to close also on the Enter key. How and where should I specify the @keypress.enter = "close" handler?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex, 2020-02-23
@choupa

Details here
https://qna.habr.com/answer?answer_id=1536519#answ...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question