如何在 Ace Editor 中启用实时语法检查 [英] How do I enable Live Syntax Checking in the Ace Editor

查看:112
本文介绍了如何在 Ace Editor 中启用实时语法检查的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Ace 编辑器具有 实时语法检查,它可以检查代码键入语法错误.

Ace Editor has Live Syntax Checking, which can check code as it's being typed for syntax errors.

我有一个 Rails 3.2 站点,每个编码页面都包含 Ace 文件.我在 javascript 中添加了一个 require 语句来告诉 Ace 工作文件在哪里,但它仍然不起作用.如何让实时语法检查工作?

I have a Rails 3.2 site with the Ace file included on each coding page. I added a require statement to the javascript to tell Ace where the worker file is, but it's still not working. How do I get Live Syntax checking to work?

每个编码页面包括:

<%= javascript_include_tag "ace-src/ace.js" %>
<%= javascript_include_tag "ace-editor" %>

Ace 文件位于 ace-src 文件夹中.我将此代码添加到 ace-editor.js:

The Ace files are located in the ace-src folder. I aded this code to ace-editor.js:

require("ace/config").set("workerPath", "/assets/ace-src");

推荐答案

语法检查是通过加载 http://www.learneroo.com/assets/ace-src/worker-javascript.js 文件,但在您的站点中该文件似乎是空的.我只看到 ; 在里面.
在我之前展示的 jsfiddle http://jsbin.com/ojijeb/432/edit 中,它由于对网络工作者的跨域限制(我没有注意到,因为使用 --disable-web-security 运行 chrome)而不起作用,但由于最新的 Ace 更新,它现在可以工作.

Syntax checking is done via webworker which loads http://www.learneroo.com/assets/ace-src/worker-javascript.js file, but in your site that file seems to be empty. I only see ; in it.
In the jsfiddle i showed earlier http://jsbin.com/ojijeb/432/edit, it didn't work because of cross origin restrictions on web workers (which i didn't notice since was running chrome with --disable-web-security), but thanks to latest Ace update, it works now.

这篇关于如何在 Ace Editor 中启用实时语法检查的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆