我正在尝试在ace编辑器中捕获换行事件。每次用户按下输入行更改,console.log显示当前行号。我试图执行以下代码。
editor.getSession().getRowLength().on('change', function(event) {
if (lineno ==1){
//execute abc}
else if (lineno==2){
//execute xyz}
});
我收到以下错误
tryit-ide.js:20 Uncaught TypeError: editor.getSession(...).getRowLength(...).on is not a function
at tryit-ide.js:20
at setUp (arch_ace-editor.js?hash=d1163619d62832acc5c961ddb94093c49630a447:78)
at callback (arch_ace-editor.js?hash=d1163619d62832acc5c961ddb94093c49630a447:98)
at arch_ace-editor.js?hash=d1163619d62832acc5c961ddb94093c49630a447:111
at XMLHttpRequest.request.onreadystatechange (arch_ace-editor.js?hash=d1163619d62832acc5c961ddb94093c49630a447:53)
谢谢。
答案 0 :(得分:0)
错误只表示您要在数字上添加事件侦听器。尝试
editor.session.on('change', function(delta) {
var lineno = delta.start.row
if (lineno ==1){
//execute abc}
else if (lineno==2){
//execute xyz}
});