【问题标题】:Why can't summernote find the jquery already included in the gwtbootstrap3为什么summernote找不到gwtbootstrap3中已经包含的jquery
【发布时间】:2017-10-26 21:19:17
【问题描述】:

基本问题是:gwtbootstrap3 是否已经包含 jquery(我想是的,见下文)。如果是这样,为什么summernote 不能引用它。我找到了这个答案here,但我仍然不确定如何继续。

我将 Summernote 添加到我的 GWTBootstrap3 项目中。然后,我将以下链接添加到我的 HTML 页面,如 summernote.org 上所述。这完美地工作。虽然我想确保只有必要的链接或包含在我的项目中。

<!--  Summernote required includes BEGIN-->
<!-- include libraries(jQuery, bootstrap) -->
<link 
href="http://netdna.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.css" 
rel="stylesheet"> 
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.js">
</script> 
<script 
src="http://netdna.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.js">
</script>

<!-- include summernote css/js-->
<link 
href="http://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.3/summernote.css" 
rel="stylesheet">
<script 
src="http://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.3/summernote.js">
</script>
<!--  Summernote required includes END-->

据我了解,gwtbootstrap3 已经使用 jquery。所以我决定注释掉jquery插件。现在的问题是 Summernote 在我的 chrome 浏览器的 Web 控制台中失败并出现以下错误:

未捕获的类型错误:无法读取未定义的属性“fn”

at summernote.js:460
at summernote.js:21
at summernote.js:23

很明显,this 指的是缺少的 jquery(因为第 460 行指的是 ...)

isWebkit: !isEdge && /webkit/i.test(userAgent),
isChrome: !isEdge && /chrome/i.test(userAgent),
isSafari: !isEdge && /safari/i.test(userAgent),
browserVersion: browserVersion,
jqueryVersion: parseFloat($.fn.jquery), <!-- LINE 460 !!! -->
isSupportAmd: isSupportAmd,
hasCodeMirror: hasCodeMirror,
isFontInstalled: isFontInstalled,
isW3CRangeSupport: !!document.createRange

所以归结为一个问题,为什么summernote 不能引用gwtbootstrap3 包中已经包含的jquery?使用 NoRessource 并手动包含所有必要的文件会有什么不同?那能解决问题吗?需要手动包含哪些文件以及我必须如何/在哪里包含它们?

最好的问候 汉内斯

【问题讨论】:

  • 我认为这是命名空间的问题。最好的办法是下载 gwtbootstrap 源,看看它们如何以及在何处引用 jQuery(通过哪个命名空间)并执行相同操作(通过 jQuery 在其源中进行简单的文本搜索就足够了)。还要确保在您调用它时,jQuery 已加载(我认为 gwtbootstrap 以异步方式加载内容)

标签: jquery summernote gwtbootstrap3


【解决方案1】:

我导入上面列出的链接的原因是,当开始在 gwtbootstrap3 中使用 Summernote 时,它​​不起作用。即它根本不会出现。但原因不是我需要导入上面提到的链接。这可能是我犯的其他一些错误(或 Eclipse 的一些令人耳目一新的问题)。使长话短说。不必导入 Summernote.org 上列出的那些链接。为什么?因为它们已经包含在 Summernote 的 gwtbootstrap3-extras 中。所以确切地说,导入这些链接是相当有害的,因为当有两个单独的 jquery 实例运行时,您可能会遇到奇怪的问题。 所以答案是。不要导入它,一切都很好。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-03-29
    • 1970-01-01
    • 2020-11-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多