我在检查器中收到以下错误。
Uncaught TypeError: Cannot read property 'cssClass' of undefined ace.js:15750
setTheme和setMode与ace.js在同一目录中。
以下是HTML标记:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>
Ace is the Place
</title>
<style type="text/css" media="screen">
#editor {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
}
</style>
</head>
<body>
Hello World!
<div id="editor"></div>
<script src="bower_components/ace/build/src/ace.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
var editor = ace.edit("editor");
editor.setTheme("bower_components/ace/build/src/monokai");
editor.getSession().setMode("bower_components/ace/build/src/html");
</script>
</body>
</html>
答案 0 :(得分:0)
没有名为"bower_components/ace/build/src/monokai"
的文件
editor.setTheme("ace/theme/monokai");
editor.session.setMode("ace/mode/html");
代替。这将起作用,因为Ace具有以"ace"
开头的路径的特殊映射。