1、template

<el-select v-model="form.test" clearable filterable remote :remote-method="remoteCustName" :loading="loading" @clear="remoteCustName">
</el-select>

2、

<script>
export default {
  data () {
    return {
      form: {
        test: ''
      },
      loading: false
    }
  },
  watch: {
    'form.test': {
      deep: true,
      handler (newVal, oldVal) {
    // 为了不请求多次接口可以加上函数节流,具体方法可以查看 点击查看第四点
        this.inputCustName()
      }
    }
  },
  mounted () {
    this.inputCustName()
  },
  methods: {
    remoteCustName (test) {
      // 实时改变v-model值,才会触发watch监听
      this.form.test = test
    },
    inputCustName (test = '') {
      this.loading = true
      // 接口请求开始
    },
  }
}
</script>

 

相关文章:

  • 2022-12-23
  • 2021-06-30
  • 2021-08-15
  • 2022-12-23
  • 2022-01-19
猜你喜欢
  • 2022-12-23
  • 2022-01-08
  • 2022-12-23
  • 2021-12-03
  • 2021-08-04
  • 2021-07-24
相关资源
相似解决方案