如何在Ace Editor中使用美化? [英] How do I use beautify in Ace Editor?

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

问题描述

我已经在Ace编辑器中找到了美化扩展程序,但是我没有看到任何使用它的示例。这是我到目前为止的内容:

I've found the beautify extension in Ace editor but I don't see any examples of how to use it. Here's what I have so far:

var beautiful = ace.require("ace/ext/beautify");
beautiful.beautify();

但我得到了错误:

Result of expression 'e' [undefined] is not an object.


推荐答案

看起来像这样:

var beautify = ace.require("ace/ext/beautify"); // get reference to extension
var editor = ace.edit("editor"); // get reference to editor
beautify.beautify(editor.session);

它要求您传入Ace Editor会话作为第一个参数。在我最初的问题中,我没有传递任何变量,这引发了错误。

It requires that you pass in the Ace Editor session as the first parameter. In my original question I did not pass in any variables and that was throwing an error.

注意:扩展发行说明中提到的效果不佳。它不能很好地使用。

Note: It did not work well which were mentioned on the extensions release notes. It was not working well enough to use.

这篇关于如何在Ace Editor中使用美化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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