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

查看:51
本文介绍了如何在 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 was mentioned on the extensions release notes. It was not working well enough to use.

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

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