问题如上:
我怀疑select 多次执行chang事情,可以使用计时器延迟尝试一下,但我没去深究,使用了另一种方法
<Select v-model="pagination.deviceid"
ref="device"
filterable
clearable
@on-query-change="getlist"
@on-select="deviceSelect"
@on-clear="cleardevice"
:not-found-text="(loading?'搜索中':(allQXList.length===0?'暂无匹配数据':''))"
>
<Option v-for="(item,index) in allQXList" :value="item.value" :label="item.name" placeholder="请选择" :key="(item,index)" :title="item.name" :style="item.online?'color:#000':'color:#bbb'">{{ item.label }}</Option>
</Select>
getlist:function(query,type){
let _this = this;
_this.from_pagination.query = '';
if(query && query != ''){
_this.from_pagination.query = query;
}
if(_this.areacode && _this.areacode != ''){
_this.from_pagination.dept = _this.areacode
}else{
_this.from_pagination.dept = 'all'
}
_this.allQXList = [];
//获取最新数据使用
_this.from_pagination.lastData=JSON.parse(JSON.stringify(_this.from_pagination.lastData+1));
_this.loading = true;
return new Promise((resolve, reject) => {
util.postNotLoading('XXXX', _this.from_pagination).then(body => {
if (body && body.success && _this.from_pagination.lastData == body.lastData) {
}
_this.loading = false;
});
})
},
deviceSelect:function(val){
let _this = this;
setTimeout(() => {
_this.pagination.deviceid = val.value;
_this.$forceUpdate();
}, 500);
},
cleardevice:function(){
let _this = this;
_this.pagination.deviceid = '';
},