$("#companyNameInput").typeahead({
source: function (query, process) {
$.ajax({
url: basePath +'business/getBusinessByName',
type: 'post',
data: {name: query},
success: function (response) {
if(response.code==200&&response.data){
returnValue=true;
process(response.data);//这里就是下面item的值
}else if(response.data){
returnValue=false;
}
},
});
},
delay: 1,// 延时1秒
fitToElement: false,// 选项框宽度与输入框一致
items: 10,// 提示数量上限
minLength: 2,
autoSelect: false,
displayText: function(item) {//这里就是上面process的值
var shipInfo = item;
var name = shipInfo.businessName;
return name;
},
afterSelect: function(item) {
this.$element
.val(item.businessName)
.text(item.businessName).change();
}
});
标签:function,Vue,false,补全,process,item,typeahead,data,response
来源: https://blog.csdn.net/fujianmin19910915/article/details/94600849