iview表格搜索功能

template中:
<Input v-model.trim="tagData.name" :search="true" enter-button size="small" class="fr mar-r16 wd-20P" @on-search="() => this.getUserFn(tagData.name)"/>
 
methods中:
getUserFn (item) {
  // console.log(item)
  let name = this.$route.params.name
  this.$api.ceph(this.zone).getUser(name)
    .then(res => {
      console.log(res)
      let array = []
      if (item == ('' || null)) {
        this.tagData = res.data.data
      }else {
        let arr = res.data.data
        for (let i=0; i<arr.length; i++) {
        // console.log(arr[i].name)
        if (arr[i].name.indexOf(item)>-1) {
          // console.log(arr[i])
          array.push(arr[i])
        }
     }
     this.tagData = array
    }
  })
  .catch()
}
原文地址:https://www.cnblogs.com/limengyao/p/9729624.html