JQuery-无法读取属性'编辑器'的未定义
JQuery - cannot read property 'Editor' of undefined
我正在尝试几个所见即所得HTML5/JQuery编辑器。然而,对于Bootstrap WISWYG和Summernote,我得到了未定义的"cannot read property"fn"或未定义的"不能读取property"Editor"。我只是在使用GitHub上的标准文件。有人熟悉使用JQuery插件时出现的这些错误吗?
编辑
我现在正在尝试Bootstrap WISWYG
我体内有
<div id="editor">Editor</div>
在我的js中,我有
$(document).ready(function() {
$('#editor').wysihtml5();
});
但是,我得到的错误是:无法读取未定义(第157行)的属性"Editor"
第157行:
var editor = new wysi.Editor(this.el[0], options);
JSFiddle:http://jsfiddle.net/MgcDU/8125/
编辑2
我忘了包含一个JS文件。然而,在包括它之后,我得到了一个新的错误:
Uncaught TypeError: Cannot read property 'firstChild' of undefined
错误所指的代码行:
if (isString) {
element = wysihtml5.dom.getAsDom(elementOrHtml, context);
} else {
element = elementOrHtml;
}
while (element.firstChild) <<<Error
问题是您使用的是DIV
元素而不是textarea
,还缺少依赖项。检查Bootstrap WYSIHTML5页面,它说:
依赖项:
- 引导程序-wyshtml5.js
- 引导程序-wyshtml5.css
- wysihtml5
- Twitter引导程序
然后你的文档应该看起来像:
<!DOCTYPE html>
<header>
<title>HTML5 Editor</title>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<!-- Of course place sources in your own server, do not leech bandwidth -->
<script type="text/javascript" src="http://jhollingworth.github.io/bootstrap-wysihtml5/lib/js/wysihtml5-0.3.0.js"></script>
<script type="text/javascript" src="http://jhollingworth.github.io/bootstrap-wysihtml5/lib/js/bootstrap.min.js"></script>
<script type="text/javascript" src="http://jhollingworth.github.io/bootstrap-wysihtml5/src/bootstrap-wysihtml5.js"></script>
<link rel="stylesheet" type="text/css" href="http://jhollingworth.github.io/lib/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="http://jhollingworth.github.io/src/bootstrap-wysihtml5.css">
</header>
<body>
<textarea class="editor"></textarea>
<script type="text/javascript">
$(document).ready(function(){
$('.editor').wysihtml5();
});
</script>
</body>
如需进一步参考,请查看:Wysihtml5#用法
"cannot read property 'fn' of undefined"
通常意味着脚本没有将脚本加载到DOM中。您可能缺少jQuery文件?我经常注意到,jQuery脚本在之前直接加载在HTML的底部已经成为一种惯例
</body>
但是,如果我在头中只加载了一个Jquery文件,同时在html文件的底部加载了其他Jquery插件脚本,那么它总是很好。
相关文章:
- Socket.io“侦听器未定义”
- Google Drive SDK示例python DrEdit不工作(身份验证时闪烁,编辑器未显示)
- jQuery数据表编辑器未初始化
- Ace 编辑器:未捕获的引用错误:窗口未定义
- Notepadd++ 或任何编辑器 - 自定义自动完成
- 弗罗阿拉编辑器 - 自定义对话框
- Javascript或PHP中是否有任何画布/布局编辑器用于定义自定义文档布局
- Firefox扩展+TCP:“;导航器未定义”;
- 引导程序wysiwyg编辑器未显示
- Tinymce编辑器未显示在某些文本区域中
- Aloha编辑器-未捕获的ReferenceError: Aloha未定义
- wysiwyg编辑器未显示活动按钮
- 数据表编辑器未发送ID
- CK编辑器-未捕获类型错误:无法读取属性'的空在Chrome
- 编辑器自定义样式的img不显示在下拉列表中
- 谷歌标记管理器未定义
- 我如何访问在谷歌脚本编辑器之外定义的函数
- 夏日笔记编辑器未打开(laravel 5.2)
- ACE编辑器自定义突出显示规则
- Cordova-plugin-contacts离开导航器.未定义联系人