之前成功创建了一个Ace编辑器,但是最近在做一个叫CodeProjects的网站,想放一个Ace编辑器进去。每次尝试时,它只显示文本function foo(items) {
var x = "All this is syntax highlighted";
return x;
}
。在页面http://ace.c9.io/#nav=embedding&api=ace上,它说您只需要代码:
<!DOCTYPE html>
<html lang="en">
<head>
<title>ACE in Action</title>
<style type="text/css" media="screen">
#editor {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
}
</style>
</head>
<body>
<div id="editor">function foo(items) {
var x = "All this is syntax highlighted";
return x;
}
</div>
<script src="/ace-builds/src-noconflict/ace.js" type="text/javascript" charset="utf-8"></script>
<script>
var editor = ace.edit("editor");
editor.setTheme("ace/theme/monokai");
editor.getSession().setMode("ace/mode/javascript");
</script>
</body>
但是当我尝试嵌入它(或者甚至只是制作编辑器,而不是网站)时,它再次只显示function foo(items) { var x = "All this is syntax highlighted"; return x; }
有什么建议么?