1

例如,我想同时在“名称”和“代码”字段中搜索单词。我怎样才能做到这一点?可能是这样的:getValue:“名称”,“代码”,

var options = {
	url: "http://easyautocomplete.com/resources/countries.json",

	getValue: "name",

	list: {
		match: {
			enabled: true
		}
	}
};

$("#provider").easyAutocomplete(options);
<html lang="en">
<head>
  <meta charset="utf-8">

  <title>Test</title>

  <!--[if lt IE 9]>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.js"></script>
  <![endif]-->
</head>

<body>
<input type="text" id="provider"/>


  <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://easyautocomplete.com/dist/jquery.easy-autocomplete.min.js"></script>
</body>
</html>

4

1 回答 1

0

您应该能够将函数传递给 getValue 选项,如下所示:

     getValue: function(element) {
         var my_value = element.name + ' ' + element.code;
         return my_value;
     },

有关更多信息,请参阅他们的文档

于 2019-08-14T13:54:37.963 回答