远程搜索

https://mp.weixin.qq.com/s?src=11&timestamp=1670311182&ver=4209&signature=1wqQNR9GM4aduhyGA4sEa9NJqhwQFTDImC454pJb8NfethaiFM5grcvywp98OONDWCP7IPOiYeZPyM-wA3es4TzJ7LGg-UWGXmNLn4-tOcS4poUpY4aoz7j8froY6iDM&new=1

  remoteMethod

debounce使用

例如远程搜索时需要通过接口动态的获取数据,若是每次用户输入都接口请求,是浪费带宽和性能的

当一个按钮多次点击时会导致多次触发事件,可以结合场景是否立即执行immediate

<Select :remote-method="remoteMethod">
    <Option v-for="item in temoteList" :value="item.value" :key="item.id">{{item.label}}</Option>
</Select>
import {debounce} from 'lodash'

methods:{
    remoteMethod:debounce(function (query) {
        // to do ...
       // this 的指向没有问题
    }, 200),
}

 

 

posted @ 2022-12-06 15:21  papering  阅读(60)  评论(0编辑  收藏  举报