简体   繁体   English

Bootstrap .dropdown()“Uncaught TypeError:undefined不是函数”

[英]Bootstrap .dropdown() “Uncaught TypeError: undefined is not a function”

I know this question has been asked before, but somehow none of the fixes for other people have worked for me. 我知道之前已经问过这个问题,但不知怎样,其他人的修复工作都没有对我有用。 I have a feeling it has something to do with importing my plugins. 我觉得它与导入我的插件有关。 When clicking a field in a bootstrap dropdown box I get "undefined is not a function" in the console for this line of code: 单击bootstrap下拉框中的字段时,我在控制台中为此行代码获取“undefined is a function”:

$target.closest( '.btn-group' )
     .find( '[data-bind="label"]' ).text( $target.text() )
        .end()
     .children( 'dropdown-toggle' ).dropdown('toggle');

Here's my import code in my HTML: 这是我的HTML中的导入代码:

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script type="application/javascript" data-main="static/js/main" src="static/js/libs/require/2.1.11/require.js"></script>
<script src="static/js/libs/bootstrap/bootstrap.min.js"></script>
<link href="static/css/bootstrap.min.css" media="screen" rel="stylesheet" type="text/css">

Whenever I click the dropdown box I also get this error in the "Network" tab of my console, it says that the request was cancelled: 每当我单击下拉框时,我也会在控制台的“网络”选项卡中收到此错误,它表示请求已取消:

file:///home/chad/.config/google-chrome/Default/Extensions/gkojfkhlekighikafcpjkiklfbnlmeio/1.6.222_0/js/jquery.min.map

Any help on this would be greatly appreciated! 任何有关这方面的帮助将不胜感激! I've been pulling my hair out over it for hours. 我已经把头发拉了几个小时。

Long shot here, but are you using the chrome extension called "Hola" ? 在这里远射,但你使用名为“Hola”的镀铬扩展吗? I noticed this message 我注意到了这条消息

Denying load of chrome-extension://gkojfkhlekighikafcpjkiklfbnlmeio/js/jquery.min.map. Resources must be listed in the web_accessible_resources manifest key in order to be loaded by pages outside the extension.

while testing a web app im developing and found out that it was that extension causing the error, just disabled it and the message didnt appear anymore. 测试一个正在开发的Web应用程序,发现它是导致错误的扩展,只是禁用它,消息不再出现。 Im also using bootstrap, dont know if its related to that. 我也使用bootstrap,不知道它是否与之相关。

The code after the "//" is the id of the extension, you can compare it with the ids in the Chrome extension configuration, see this image and notice the id is the same as in the error. “//”后面的代码是扩展程序的ID,您可以将其与Chrome扩展程序配置中的ID进行比较,请参阅此图片并注意该ID与错误中的ID相同。

Hope this helps. 希望这可以帮助。

Maybe your script tags are out of order? 也许你的脚本标签出了故障?

<script type="application/javascript" data-main="static/js/main" src="static/js/libs/require/2.1.11/require.js"></script>

Which includes the call for dropdown() is probably being executed before: 其中包括对dropdown()的调用可能在执行之前执行:

<script src="static/js/libs/bootstrap/bootstrap.min.js"></script>

Which defines the dropdown() method. 其中定义了dropdown()方法。

Does the code in the require app get wrapped in a $(function() {}) ? require app中的代码是否包含在$(function() {})

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

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