react-monaco-editor格式化

  1. 引入react-monaco-editor
import Monaca from 'react-monaco-editor';

react-monaco-editor格式化
2、配置

const editorDidMountHandle = (editor: any, monaco: any) => {
    editor.getAction('editor.action.formatDocument').run()  //格式化
  }
 <Monaca
            height={monacaHeight}
            language="json"
            theme="vs-light"
            options={{ selectOnLineNumbers: true, automaticLayout: true, wordWrap: 'wordWrapColumn', wrappingStrategy: 'simple', wordWrapBreakBeforeCharacters: ',', wordWrapBreakAfterCharacters: ',', disableLayerHinting: true }}
            value={config ? config : ''}
            onChange={onChangeHandle}
            editorDidMount={editorDidMountHandle}
          />

react-monaco-editor格式化
3、格式化成功后的效果
react-monaco-editor格式化

上一篇:求逆手算步骤


下一篇:924891-73-6 苯甲酸,4,4‘-(21H,23H-卟吩-5,15-二酰基)双-1,1‘-二乙酯