运行editor.setTheme('libs/ace/theme/twilight')
将在根文件夹中查找theme-twilight.js
。
我尝试查看文档但没有找到任何帮助。
另外,工作人员,是否需要使用任何语言,或者是否可以选择关闭它们?
同样,在文档中没有找到解决方案。
在找了好一阵子后,我找到了这两个:
ace.config.set('basePath', '/libs/ace');
editor.getSession().setUseWorker(false);
你是个英雄,需要 basePath 属性并且已经找了好几天了。 谢谢你。
为了将来参考,这是一个完整的示例(模仿官方 ace 网站上的嵌入示例),用于在其他地方使用 ace.js(我将它连接到 libs.min.js):
<script src="libs.min.js" type="text/javascript" charset="utf-8"></script>
<script>
ace.config.set('basePath', '/ace-builds/src-noconflict');
var editor = ace.edit("editor");
editor.setTheme("ace/theme/monokai");
editor.getSession().setMode("ace/mode/javascript");
</script>
对于那些努力让它在生产环境中工作的人,我发现不仅设置basePath
,而且设置modePath
和themePath
有时是加载模式所必需的和主题:
ace.config.set('basePath', '/ace-builds/src-noconflict');
ace.config.set('modePath', '/ace-builds/src-noconflict');
ace.config.set('themePath', '/ace-builds/src-noconflict');
@efatsi能否请您与我分享我们如何使用https://github.com/fxmontigny/ng2-ace-editor 进行angular 6 项目。 我也面临同样的问题。
抱歉@PrabakarKaruppasamy ,我没有任何角度经验。 祝你好运!
@PrabakarKaruppasamy - 你能让它工作吗? 您可以查看https://stackoverflow.com/questions/60177855/theme-and-mode-path-infer-issue-with-ace-js-and-angular 的任何更改
最有用的评论
在找了好一阵子后,我找到了这两个:
ace.config.set('basePath', '/libs/ace');
editor.getSession().setUseWorker(false);