简体   繁体   English

Ace Editor JSON格式检查不适用于“ localhost://”

[英]Ace Editor JSON format check not work in “localhost://”

This is my code in "file://": 这是我在“ file://”中的代码:

我的代码图像。点击查看

It works. 有用。 But when I put it on the "127.0.0.1". 但是当我把它放在“ 127.0.0.1”上时。

在此处输入图片说明

There was an error. 有一个错误。 GET http://localhost:8080/worker-json.js 404 (Not Found) GET http:// localhost:8080 / worker-json.js 404(未找到)

I've done the following and the problem fixed: 我已经完成以下工作,并解决了问题:

ace.config.set("workerPath", "assets/js/plugins/editors/ace/") ace.config.set(“ workerPath”,“资产/ js /插件/ editors / ace /”)

Edit: I was facing an issue with multiple web workers being created each time Angular view is created, so with a quick search I found also a fix to prevent Ace from creating web workers multiple times, here is my code to init the editor: 编辑:我面临一个问题,每次创建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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM