<input v-model="searchInput" @input="handleInput"/>
2. data里加一个timeoutId: ""
3. methods里写:
handleInput() { if (this.timeoutId) { clearTimeout(this.timeoutId) } this.timeoutId = setTimeout(this.query, 600) }, query(){ //下面写请求数据的代码 }
参考原文地址:https://blog.csdn.net/EllynX/article/details/112392479