WEI A
WEI A

Reputation: 401

How to use Vue to call API when the focus leaves the input box?

my just encountered difficulties when learning vue, and I don't know how to implement it. I hope someone can help me!

First, I declare that my English is not good, but I try to express my problem completely.

The current project hopes to call the API after leaving the input box after entering the content in the input box, but I will only delay him by 0.4 seconds. I don't know how to change the code to call the API when I leave the input box. I found an onBlur event on the Internet, but I still don't know how to write it, because I am really new to vue. I hope I can get your help. thank you.

This is my program project

Upvotes: 0

Views: 602

Answers (1)

DannyFeliz
DannyFeliz

Reputation: 802

You only need to replace the @input event with @blur

<el-input v-model="inputData" placeholder="Content" @blur="delayFetch" />

Working demo

Upvotes: 2

Related Questions