Initialize the
// Initialize the editor to make sure the DOM is rendered
this.monacoEditor = monaco.editor.create(this.$refs.jsonContainer, {
value: ' '.// The editor initially displays text
language: 'json'./ / language
automaticLayout: true.// Automatic layout
theme: 'vs'.// There are three official themes: VS, HC-Black, or VS-Dark
minimap: { // Close the minimap
enabled: false,},lineNumbers: 'off'.// Hide the control line number
});
Copy the code
Destroy editor
this.monacoEditor.dispose();
Copy the code
Get the value of the editor in real time
this.monacoEditor.onDidChangeModelContent(() = > {
this.monacoEditor.getValue() // Get the statement in the editor
})
Copy the code
Sets the value of the editor
this.monacoEditor.setValue(newValue)
More attributes set reference: www.jianshu.com/p/0c9fc9267…