简体   繁体   English

TypeError:$(…).easyAutocomplete不是函数

[英]TypeError: $(…).easyAutocomplete is not a function

I am trying to follow jquery easyAutocomplete docs and getting this error. 我正在尝试遵循jquery easyAutocomplete文档并获取此错误。 I know this is a very common question and there have been asked a handful in SO. 我知道这是一个非常普遍的问题,因此已经提出了一些建议。 But none of them seems to erase my error. 但是它们似乎都无法消除我的错误。 Here is my code 这是我的代码

test.js test.js

var options = {
  url: "places.json",
  getValue: "name",

  list: {
    match: {
      enabled: true
    }
  },

  theme: "square"
};

$("#textbox").easyAutocomplete(options);

html 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: json:

[
  { "name": "Afghanistan", "code": "AF" },
  { "name": "Aland Islands", "code": "AX" },
  { "name": "Albania", "code": "AL" },
  { "name": "Algeria", "code": "DZ" },
  { "name": "American Samoa", "code": "AS" }
]

In the EasyAutocomplete guide , it says: EasyAutocomplete指南中 ,它说:

In order to use EasyAutocomplete, add these files in header section of your page. 为了使用EasyAutocomplete,请将这些文件添加到页面的页眉部分。

 <!-- 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. 记住要包括jQuery文件。 You can download library from the jQuery website . 您可以从jQuery网站下载库。 Best practice is to use CDN server: 最佳实践是使用CDN服务器:

 <!-- Using jQuery with a CDN --> <script src="//code.jquery.com/jquery-1.11.2.min.js"></script> 

Based on this, you'll need to include jquery.easy-autocomplete.min.js after jQuery and before your own code. 基于此,您需要在jQuery之后和您自己的代码之前包含jquery.easy-autocomplete.min.js You should also include easy-autocomplete.min.css . 您还应该包含easy-autocomplete.min.css

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM