我已经为 PHP 实现了 Ace 编辑器设置(工作正常),但是当我尝试使用 Ace 的 API 设置其他选项时,我在控制台中收到警告。
这是用于初始化编辑器并尝试设置选项的代码;
ace.require("ace/ext/language_tools");
ace.require("ace/ext/emmet");
// PHP
var phpeditor = ace.edit("php_inc");
phpeditor.setTheme("ace/theme/dreamweaver");
phpeditor.getSession().setMode("ace/mode/php");
phpeditor.setOptions({
enableSnippets: true,
enableLiveAutoComplete: true,
enableBasicAutocompletion: true,
showPrintMargin: settings.showPrintMargin,
useSoftTabs: false,
fontSize: settings.fontSize,
showInvisibles: settings.showInvisibles,
behavioursEnabled: settings.behavioursEnabled,
tabSize: settings.tabSize,
useWrapMode: settings.useWrapMode,
useWorker: settings.useWorker,
setHighlightActiveLine: false,
enableEmmet: true
});
这是我收到的控制台警告;
misspelled option "enableSnippets" ace.js?ver=3.9.1:5207
misspelled option "enableLiveAutoComplete" ace.js?ver=3.9.1:5207
misspelled option "enableBasicAutocompletion" ace.js?ver=3.9.1:5207
misspelled option "setHighlightActiveLine" ace.js?ver=3.9.1:5207
misspelled option "enableEmmet" ace.js?ver=3.9.1:5207
任何帮助将不胜感激。
最佳答案
- 您需要为您使用的扩展程序包含脚本文件,请参阅https://github.com/ajaxorg/ace-builds/blob/v1.1.4/demo/autocompletion.html#L28
- 选项名称是
"enableLiveAutocompletion"
而不是"enableLiveAutoComplete"
https://github.com/ajaxorg/ace/blob/v1.1.4/lib/ace/ext/language_tools.js#L186 - 选项名称中没有
set
,所以应该是highlightActiveLine
您可以通过运行 Object.keys(editor.$options)
查看所有可用选项的列表
关于javascript - 拼写错误的 Ace 编辑器选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24651222/