Skip to content

Commit

Permalink
fix: 补充单文件编辑器用法
Browse files Browse the repository at this point in the history
  • Loading branch information
maxiaobo01 committed May 9, 2022
1 parent 9d2eda9 commit 9269af8
Showing 1 changed file with 52 additions and 1 deletion.
53 changes: 52 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
### 安装

```
nenpm install react-monaco-editor-lite
npm install react-monaco-editor-lite
```

### 使用

#### 多文件编辑器

```js

import { MultiEditor } from 'react-monaco-editor-lite';
Expand Down Expand Up @@ -89,6 +91,55 @@ export function minus(a, b) {
export default IDE;
```

#### 单文件编辑器

```js
import { SingleEditor } from 'react-monaco-editor-lite';
import React, { useState } from 'react';

function SingleIDE() {
const [loc] = useState({
start: {
line: 3,
column: 1
},
end: {
line: 4,
column: 1
}
});
const [value, setValue] = useState(`
export function add(a, b) {
return a + b;
}
export function minus(a, b) {
return a - b;
}
`);
const onChange = (v) => {
setValue(v);
}

return (
<div style={{
width: '800px',
height: '800px',
}}>
<SingleEditor
value={value}
onChange={onChange}
loc={loc}
options={{
}} />
</div>
)
};

export default SingleIDE;
```


### 组件参数及方法

查看此[文档](https://x-orpheus.github.io/react-monaco-editor-lite/public/docs/index.html)

0 comments on commit 9269af8

Please sign in to comment.