$(...)。popover不是一个函数 [英] $(...).popover is not a function

查看:91
本文介绍了$(...)。popover不是一个函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里看了很多关于这个问题的帖子,但是它们似乎都没有解决我的问题。

I have looked through quite a few posts on here dealing with this issue, but none of them seem to solve my problem.

我已经导入了jQuery和Bootstrap js文件的顺序正确。像bootstrap面板这样的东西对我来说非常好。

I have imported the jQuery and Bootstrap js files in the right order. Things such as bootstrap panels are working perfectly fine for me.

我的脚本导入是这样的:

My script imports are like this:

   <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
   <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
   <link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet">

然而,当我尝试

 $('[data-toggle="popover"]').popover();

我在Chrome控制台中收到以下消息:

I get the following message in the Chrome console:

 Uncaught TypeError: $(...).popover is not a function

起初我觉得popover并没有包含在CDN的副本中,所以我继续下载了一份包含所有插件的本地副本:

At first I thought maybe popover was not being included in CDN's copy, so I went ahead and downloaded a local copy with all the plugins included from here:

http://getbootstrap.com/customize/

并得到相同的错误消息(将脚本标记重新指向本地js文件)。

and got the same error message (re-pointed the script tags towards the local js file).

搜索popoverbootstrap.min.js文件:

Doing a search for "popover" the bootstrap.min.js file:

http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js

显示popover包含在文件中。

Shows that popover is included in the file.

推荐答案

既然你已经声明你已经正确地包含了jQuery和其他库,那么可能的情况就是页面中可能有多个jQuery实例。

Since you have stated you have included jQuery and the other libraries correctly, 1 possible case is there could be multiple instances of jQuery in the page.

因此,基于所使用的服务器技术,搜索jQuery的重复版本,如果有任何删除它们(如果不需要,则必须考虑 noConflict()使用)。

So based on the server technology used, search for a duplicate version of jQuery and if there is any remove them(if not needed else will have to think about noConflict() use).

如果有重复的jQuery实例,问题是jQuery插件附加的版本可能与您访问的版本不同,此时使用插件的插件将无法找到。

In case of duplicate jQuery instances the problem is the jQuery version to which the plugin is attached might be different from the one which you are accessing to use the plugin at that point the plugin will not be found.

  • https://learn.jquery.com/using-jquery-core/avoid-conflicts-other-libraries/

这篇关于$(...)。popover不是一个函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆