elementui el-select使用远程搜索单选,输入内容不会触发remote-method
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>