@aligov/monaco-diff-editor
v1.0.1
Published
intro component
Downloads
22
Readme
DiffEditor
@aligov/monaco-diff-editor
intro component
API
| 参数名 | 说明 | 必填 | 类型 | 默认值 | 备注 | | ------ | ---- | ---- | ---- | ------ | ---- | | original | 原始值 | false | string | | | | value | 当前值 | true | string | | | | language | 语言 | true | string | | | | options | 配置 | false | object | | 同monaco的options |
基础用法
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import MonacoDiffEditor from '@aligov/monaco-diff-editor';
class App extends Component {
constructor(props) {
super(props)
this.editor = React.createRef();
}
getValue = () => {
console.log(this.editor.current.getValue())
}
render() {
return (
<div style={{height: 300}}>
<button onClick={this.getValue}>获取当前值</button>
<MonacoDiffEditor ref={this.editor} original="ww"/>
</div>
);
}
}
ReactDOM.render((
<App />
), mountNode);