monaco 编辑器控制组件

问题描述 投票:0回答:0

这个问题是关于monaco-react library

当我输入“hello world”之类的内容时

现在:

enter image description here

但我想要:

enter image description here

我想绝对拦截输入,因为某些原因,readOnly没用

const [value, setValue] = useState('');
<MonacoEditor
  theme="vs-light"
  width={width}
  height={height}
  language={language}
  value={value}
  onMount={handleMount}
  onChange={handleChange}
/>
const handleChange = (newValue) => {
  // no changed
  console.log(value);
  // has changed
  console.log(newValue);
  // the editor has changed like the first picture
}

如何控制编辑器?

monaco-editor
© www.soinside.com 2019 - 2024. All rights reserved.