[英]Ace Editor JSON format check not work in “localhost://”
这是我在“ file://”中的代码:
有用。 但是当我把它放在“ 127.0.0.1”上时。
有一个错误。 GET http:// localhost:8080 / worker-json.js 404(未找到)
我已经完成以下工作,并解决了问题:
ace.config.set(“ workerPath”,“资产/ js /插件/ editors / ace /”)
编辑:我面临一个问题,每次创建Angular视图时都会创建多个Web Worker,因此通过快速搜索,我还找到了一个防止Ace多次创建Web Worker的修复程序,这是我初始化编辑器的代码:
// Code running with Angular 4 CLI and WebPack updateSkecthCalcPanel() { const editor = ace.edit(this.canvasObject.sketchCalcEditor); // Selector name const aceSession = editor.getSession(); ace.config.set("workerPath", "assets/js/plugins/editors/ace/") // Folder contain the worker editor.setTheme("ace/theme/monokai"); editor.setShowPrintMargin(false); editor.setOptions({ readOnly: true, maxLines: Infinity }); aceSession.setMode("ace/mode/json"); aceSession.setValue(js_beautify(JSON.stringify(this.sketchObject), { indent_size: 2 })); // Quick-fix that allows to omit ACE problem with loading workers ace.require("ace/edit_session").EditSession.prototype.$startWorker = function () { } // Fold Code window.setTimeout(function () { aceSession.foldAll(1, aceSession.getLength()); }, 500); }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.