有没有一种方法可以通过id获取ace编辑器?
答
它看起来像我可以使用下面的代码:
ace.getEditorById = function(el) {
if (typeof el == "string") {
var _id = el;
el = document.getElementById(_id);
if (!el) {
return null;
}
if (el && el.env && el.env.editor instanceof Editor) {
return el.env.editor;
}
}
return null;
}
我想建议把它添加到核心。也许我们可以有一个ace.editors字典来跟踪它们。见问题1138。
ace.edit(“id”)已经这样做https://github.com/ajaxorg/ace/blob/v1.2.6/lib/ace/ace.js#L84-L85 –