一个这样的需求,我在输入框输入联想功能,点击下面的数据会填充到输入框,同时也绑定输入框的blur事件,blur后会影藏联想出来的列表(就是lsftest那一行),但是这样就会在点击列表那一行时,输入框里得不到值,怎么解?
<div class="popbox-dh" id="popbox-dh">
<div class="dhpop-item dhpop01">
<div>
<input type="tel" v-model="telStr" @keyup="getPhoneData | debounce 300" @focus="focusfns" @blur="blurfns" maxlength="11" placeholder="请输入客户经理手机号">
</div>
<div class="dhSel" v-show="showSel">
<p v-for="item in mobileList" @click="setPhone(item.mobile)"> {{item.mobile}} <span>({{item.name}})</span></p>
<div v-show="!mobileList.length">无此客户经理信息</div>
</div>
</div>
<div class="dhpop-item dhpop02">
<div>
<input maxlength="6" v-model="yzStr" type="tel" placeholder="请输入验证码"></div><span @click="getYzCode" id="yzCodeele" :class=\'{"disabled": yzFlag}\'>获取验证码</span>
</div>
<div class="dhpop-des fs12">请核对您购买产品的产品名称、产地、产品型号、产品标准(重量、包装)、数量、价格;如有“产品超出保质期、产品严重变质、配送一周未 到货三种情况”,您可在2日内,包装完好的情况下,我公司无条件接受退货;其他情形退货,产生的物流费、装卸费以及产品损失由您本人承担。</div>
</div>
methods: {
getPhoneData: function () {
var _that = this;
if(_that.telStr){
$.xeAjax({
url : '/suborder/v1_0/getMobileList.shtml',
datas : {
"mobile" : _that.telStr
},
succFn : function(data){
console.log(data);
_that.showSel = true;
_that.mobileList = data.mobileList;
if(!data.mobileList.length){
_that.yzFlag = true;
}
}
})
}else{
_that.showSel = false;
_that.yzFlag = true;
_that.mobileList = [];
}
},
focusfns : function(){
this.getPhoneData();
},
blurfns : function(){
var that =this;
that.showSel=false;
}
}
求大神指导,好像是先执行的Blur事件!!!!!!
你把Blur事件,放在input上面,当你点击下面的列表时,就是出发了input Blur事件,列表都隐藏了,列表的事件得不到触发的,请将Blur事件添加在 input和列表共同父类元素上面即可!本来将Blur事件移至到‘.dhpop-item’元素上试试!