javascript - 在 React-ace 中设置值时出现类型错误

标签 javascript reactjs react-ace

设置值时出现错误。我正在尝试设置 JavaScript 代码,但出现以下错误。

Document.$detectNewLine
node_modules/ace-builds/src-noconflict/ace.js:7832
  7829 | 
  7830 | 
  7831 | this.$detectNewLine = function(text) {
> 7832 |     var match = text.match(/^.*?(\r\n|\r|\n)/m);
       | ^  7833 |     this.$autoNewLine = match ? match[1] : "\n";
  7834 |     this._signal("changeNewLineMode");
  7835 | };

我的编辑器设置是

<AceEditor 
                        mode="javascript"
                        theme="github"
                        name="editor"
                        value={this.setValue}
                        editorProps={{$blockScrolling: true}}
                        setOptions={{
                            enableBasicAutocompletion: false,
                            enableLiveAutocompletion: false,
                            enableSnippets: false,
                            showLineNumbers: true,
                            tabSize: 2,
                        }}
/>```
 The setValue is

    `
    setValue = async () => {
        let demo = await this.state.getCodeFromFile.success;
        return demo;
    }`

最佳答案

您是否尝试过从 setOptions 中删除最后一个逗号?这曾经给我带来了一些问题。

它看起来像这样:

setOptions={{
                            enableBasicAutocompletion: false,
                            enableLiveAutocompletion: false,
                            enableSnippets: false,
                            showLineNumbers: true,
                            tabSize: 2
                        }}

关于javascript - 在 React-ace 中设置值时出现类型错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60835902/

相关文章:

javascript - 获取所有表单数组到JS数组

javascript - Javascript 问题(异步调用)

javascript - AntD rowSelection 功能组件

ace-editor - 如何从language_tools外部在react ace编辑器中添加自定义完成器

javascript - angularjs 指令两种方式绑定(bind)不起作用

javascript - 如何以只需要一种方法(如果可能)的方式优化我的代码?

reactjs - 如何访问 BaseComponent 或任何级别组件的 ref?

javascript - React 在添加标签时无法删除重复项

javascript - React Ace 编辑器标记突出显示整行,甚至定义了 startCol 和 endCol 以限制列

reactjs - 通过 React 测试库 (RTL) 触发 react-ace onChange