问题描述
我在compositionComplete()
this.docEditor = aceEditorBindingHandler.getEditorBySelection($(docEditorSelector);
// this.docEditor is of type AceAjax.Editor
if (this.docEditor) {
this.docEditor.getSession().on("tokenizerUpdate",() => {
// do stuff
});
}
但没有从不命中。
如果我将事件更改为在“ change
”上,则内容更改时将命中代码。
但这不是我所需要的。
有什么主意吗?有人吗?
解决方法
与更改事件不同,未同步调用令牌生成器更新。请参见下面的示例以演示其工作。
<script src=https://ajaxorg.github.io/ace-builds/src-noconflict/ace.js></script>
<script>
editor = ace.edit(null,{
mode: "ace/mode/javascript",minLines: 5,maxLines: 10,})
var log = ace.edit(null,})
document.documentElement.appendChild(editor.container)
document.documentElement.appendChild(log.container)
editor.session.on("tokenizerUpdate",() => {
log.insert("tokenizerUpdate called " + Date.now() + "\n")
})
</script>