我已经成功创建了一个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; }
有什么建议吗?
在我的网站上,它只显示为一行。 –
你使用ie8吗?在这种情况下尝试把代码预先而不是div http://jsbin.com/ojijeb/172/edit –
不,我使用铬最新更新 –