将JS文件导入到下一个JS中-获取参考错误

时间:2019-06-09 02:44:15

标签: reactjs next.js codemirror

尝试在我的Next JS项目中导入js文件时出现以下错误。

错误: 参考错误:导航器未定义

这是我用来插入文件的组件。我需要Codemirror来正确渲染python,但该组件仅在删除<​​strong> mode / python / python.js import

时有效
import Link from "next/link";
import { UnControlled as CodeMirror } from "react-codemirror2";
// import "../node_modules/codemirror/mode/python/python.js";
import "../node_modules/codemirror/lib/codemirror.css";
import "../node_modules/codemirror/theme/material.css";
import styled from "styled-components";

const CodeContainer = styled.div`
  position: absolute;
  width: 600px;
  left: 600px;
  height: 100%;
  overflow-y: auto;
  z-index: 1;
`;

const Code = () => (
  <CodeContainer>
    <CodeMirror
      value="<h1>Hello World</h1>"
      options={{
        mode: "python",
        theme: "material",
        lineNumbers: true
      }}
      onChange={(editor, data, value) => {}}
    />
  </CodeContainer>
);

export default Code;

0 个答案:

没有答案