TypeError: $(...).easyAutocomplete is not a function
TypeError: $(...).easyAutocomplete is not a function
我正在尝试遵循 jquery easyAutocomplete docs 并收到此错误。我知道这是一个非常常见的问题,并且已经在 SO 中被问过一些。但是 none 似乎消除了我的错误。这是我的代码
test.js
var options = {
url: "places.json",
getValue: "name",
list: {
match: {
enabled: true
}
},
theme: "square"
};
$("#textbox").easyAutocomplete(options);
html
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>test</title>
<link
rel="stylesheet"
href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css"
/>
</head>
<body>
<div>
Location: <br />
<br />
<input type="text" name="enterlocation" id="textbox" />
<button>enter</button>
</div>
</body>
<script src="https://code.jquery.com/jquery-3.4.1.js"></script>
<script async src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<script src="test.js"></script>
</html>
json:
[
{ "name": "Afghanistan", "code": "AF" },
{ "name": "Aland Islands", "code": "AX" },
{ "name": "Albania", "code": "AL" },
{ "name": "Algeria", "code": "DZ" },
{ "name": "American Samoa", "code": "AS" }
]
在EasyAutocomplete guide中,它说:
In order to use EasyAutocomplete, add these files in header section of
your page.
<!-- JS file -->
<script src="path/to/jquery.easy-autocomplete.min.js"></script>
<!-- CSS file -->
<link rel="stylesheet" href="path/to/easy-autocomplete.min.css">
<!-- Additional CSS Themes file - not required-->
<link rel="stylesheet" href="path/to/easy-autocomplete.themes.min.css">
Remember to include jQuery file. You can download library from the
jQuery website. Best practice is to use CDN server:
<!-- Using jQuery with a CDN -->
<script src="//code.jquery.com/jquery-1.11.2.min.js"></script>
基于此,您需要在 jQuery 之后和您自己的代码之前包含 jquery.easy-autocomplete.min.js
。您还应该包括 easy-autocomplete.min.css
.
我正在尝试遵循 jquery easyAutocomplete docs 并收到此错误。我知道这是一个非常常见的问题,并且已经在 SO 中被问过一些。但是 none 似乎消除了我的错误。这是我的代码
test.js
var options = {
url: "places.json",
getValue: "name",
list: {
match: {
enabled: true
}
},
theme: "square"
};
$("#textbox").easyAutocomplete(options);
html
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>test</title>
<link
rel="stylesheet"
href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css"
/>
</head>
<body>
<div>
Location: <br />
<br />
<input type="text" name="enterlocation" id="textbox" />
<button>enter</button>
</div>
</body>
<script src="https://code.jquery.com/jquery-3.4.1.js"></script>
<script async src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<script src="test.js"></script>
</html>
json:
[
{ "name": "Afghanistan", "code": "AF" },
{ "name": "Aland Islands", "code": "AX" },
{ "name": "Albania", "code": "AL" },
{ "name": "Algeria", "code": "DZ" },
{ "name": "American Samoa", "code": "AS" }
]
在EasyAutocomplete guide中,它说:
In order to use EasyAutocomplete, add these files in header section of your page.
<!-- JS file --> <script src="path/to/jquery.easy-autocomplete.min.js"></script> <!-- CSS file --> <link rel="stylesheet" href="path/to/easy-autocomplete.min.css"> <!-- Additional CSS Themes file - not required--> <link rel="stylesheet" href="path/to/easy-autocomplete.themes.min.css">
Remember to include jQuery file. You can download library from the jQuery website. Best practice is to use CDN server:
<!-- Using jQuery with a CDN --> <script src="//code.jquery.com/jquery-1.11.2.min.js"></script>
基于此,您需要在 jQuery 之后和您自己的代码之前包含 jquery.easy-autocomplete.min.js
。您还应该包括 easy-autocomplete.min.css
.