【发布时间】:2020-12-24 04:08:41
【问题描述】:
我希望通过我的反应组件中的值道具显示一些代码,但编辑器只是保持空白并且不显示任何值。我可以在编辑器中输入,一切似乎都在工作,包括语法突出显示。看不到错误。我错过了什么明显的东西吗?
我应该注意,我正在使用 next.js 和 react-ace,如下所示: https://github.com/mingderwang/ace-editor-with-next
这是我的主要 index.js 页面代码:
import dynamic from "next/dynamic";
const CodeEditor = dynamic(import("../components/codeEditor"), { ssr: false });
export default () => {
return (
<div>
<CodeEditor value={"for (var i=0; i < 10; i++) {\n console.log(i)\n}"} />
</div>
);
};
这里是 Ace CodeEditor 组件代码:
import ReactAce from "react-ace-editor";
import React from "react";
function CodeEditor(props) {
return (
<ReactAce
value={props.value}
mode="javascript"
theme="xcode"
setReadOnly={false}
style={{
height: "500px",
fontSize: "16px",
}}
/>
);
}
export default CodeEditor;
【问题讨论】:
标签: javascript reactjs ace-editor