Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Ace编辑器在单行上获取值_Javascript_Html_Ace Editor - Fatal编程技术网

Javascript 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

我试图在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 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不起作用