如何在Monaco编辑器中使用setValue?

时间:2018-04-25 14:26:33

标签: monaco-editor

设置Monaco编辑器文本内容的正确方法是什么,而不必担心撤消堆栈? filterAnswer(i:any) //Comparing Answer submitted by user with JSON answer { this.isRyt = this.questArrayNew1[0].isRight; if(this.isRyt == i ) { for(let k = 0 ; k < this.questArray.length ; k++) { if(this.storeArray[k] == i) { console.log(k); } else { this.counter++; //WANT TO INCREMENT ONLY ONE TIME IF IT DOESNT SATISFY THE CONDITION FOR WHOLE K=0,1,2,3.. variable } } this.storeArray[this.incCounter] = i ; console.log(this.storeArray); this.incCounter++; } else { return 0; } } 似乎在内心深处崩溃:

monacoEditor.setValue("text")

2 个答案:

答案 0 :(得分:2)

对于Google以后的旅行者,初始化编辑器后,以下代码适用于0.2.0:

editor.getModel().setValue('some value');

答案 1 :(得分:0)

问题证明我没有传入字符串,而是传入JSON对象。使用“text”进行测试也不起作用,因为amdRequire结果是异步的。

相关问题