Javascript Ace编辑器在单行上获取值
我试图在Ace编辑器的单行上获取值 根据Ace编辑器文档:Javascript Ace编辑器在单行上获取值,javascript,html,ace-editor,Javascript,Html,Ace Editor,我试图在Ace编辑器的单行上获取值 根据Ace编辑器文档: gotoLine()导航到单行 getLine()获取单行 getLines()获取多行 以下是我尝试过的: var html = ace.edit("html"); html.getSession().setMode("ace/mode/html"); html.setTheme("ace/theme/eclipse"); html.setPrintMarginColumn(false); html.resize(); var
导航到单行gotoLine()
获取单行getLine()
获取多行getLines()
var html = ace.edit("html");
html.getSession().setMode("ace/mode/html");
html.setTheme("ace/theme/eclipse");
html.setPrintMarginColumn(false);
html.resize();
var line4 = html.gotoLine(4);
var getfour = html.getLine(4);
var getfoureight = html.getLines(4,8);
gotoLine()
有效getLine()
和getLine()
不起作用
我做错了什么?
getLine
和getLine
是会话中的函数,因此需要像这样调用它们
var editor = ace.edit("html");
editor.setValue("line0 \n line1 \n line2 \n line3")
editor.session.getLine(2) // returns " line2 "
editor.session.getLines(1, 2) // returns [" line1 ", " line2 "]
不起作用是什么意思?他们返回什么或抛出什么错误?gotoLine(4)
有效吗?gotoLine()有效。getLine()和getLines不起作用