简体   繁体   中英

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

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

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

Working demo

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM