acejs 编写一个json代码编辑器
```js
import { Editor } from 'ace';
class JSONEditor extends Editor {
constructor(container, options) {
super(container, options);
this.setTheme("ace/theme/monokai");
this.getSession().setMode("ace/mode/json");
// Set the font size and line height to match the container's size.
this.setFontSize(container.clientHeight / 2);
this.getSession().setOption("lineHeight", container.clientHeight / 2);
}
setJSON(jsonString) {
this.session.setValue(JSON.stringify(jsonString, null, 4)); // Indented with 4 spaces // Indented with 4 spaces per level of nesting; // Indented with 4 spaces // Indented with 4 spaces // Indented with 4 spaces // Indented with 4 spaces // Indented with 4 spaces // Indented with 4 spaces // Indented with 4 spaces per level of nesting; per level of nesting; per level of nesting; per level of nesting; per level of nesting; per level of nesting;
}
getJSON() { return JSON.parse(this.session.getValue()); } } export default JSONEditor; ```
创作工场
免责声明:
以上内容除特别注明外均来源于网友提问,创作工场回答,未经许可,严谨转载。
点击这里>>使用🔥专业版,更聪明、更完整、更原创!