尝试在我的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;