$("#CustomerName").autocomplete({ //source: "/Test/Project/GetCompanySelectJson", source: [{ "label": "江苏灯为有限公司", "value": 2 }, { "label": "城中投资发展有限公司", "value": 4 }, { "label": "国啦为要", "value": 5 }], select: function (event, ui) { $("#CustomerName").val(ui.item.label); $("#CustomerId").val(ui.item.value); event.preventDefault(); } });使用上面的Source,autocomplete会索引出全部记录,而不是按输入的关键字,通过F12查看获得的数据,就是下面的Source值,换成下面的Source是正常使用,也就是说代码应该是没有问题的,为什么上面的Source就索引全部呢?
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/4741/viewspace-3130300/ ,如需转载,请注明出处,否则将追究法律责任。