$(...).tagsinput 不是函数

$(...).tagsinput is not a function

我一定是遗漏了一些简单的东西,但我看不到。我正在使用 Bootstrap tagsinput 插件,我正在尝试遵循此处的一些示例: http://bootstrap-tagsinput.github.io/bootstrap-tagsinput/examples/

这是我的代码:

<html>
  <head>
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/bootstrap.tagsinput/0.4.2/bootstrap-tagsinput.css" />
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
    <script src="https://cdn.jsdelivr.net/bootstrap.tagsinput/0.4.2/bootstrap-tagsinput.min.js"></script>
  </head>
  <body>
    <input id="cities" class="form-control" value="New York,London" data-role="tagsinput" type="text">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
    <script>
      $(function() {
        $('#cities').tagsinput({
          maxTags: 3
        });
      });
    </script>
  </body>
</html>

我收到以下 Javascript 错误:

tagsinput.html:15 Uncaught TypeError: $(...).tagsinput is not a function

我尝试按照 this SO answer 中的建议删除 data-role="tagsinput",但输入变成了常规文本框并且仍然出现异常。

我做错了什么?

您正在 script 标签中加载 2 jquery 分钟的文件。

删除 bootstrap-tagsinput.min.js 之后的那个,或者因为第二个是较新的版本而不是第一个。

http://jsbin.com/xarasebibi/edit?html,output

您重复了 jquery link。一个在顶部,另一个在底部。 bootstrap-tag-min 脚本只有在包含 jquery link 后才需要 linked。有关更多信息,请参见下文。希望有帮助

<html>
  <head>
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/bootstrap.tagsinput/0.4.2/bootstrap-tagsinput.css" />
  </head>
  <body>
    <input id="cities" class="form-control" value="New York,London" data-role="tagsinput" type="text">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
    <script src="https://cdn.jsdelivr.net/bootstrap.tagsinput/0.4.2/bootstrap-tagsinput.min.js"></script>
    <script>
      $(function() {
        $('#cities').tagsinput({
          maxTags: 3
        });
      });
    </script>
  </body>
</html>