【发布时间】:2022-01-24 11:21:46
【问题描述】:
我为此使用 node.js 并使用 react 作为前端,现在如何将 app.jsx 文件导入 index.js 文件? index.js
import App from "./components/app";
ReactDOM.render(<App text="Hello world"/> , document.getElementById('root'))
app.jsx
function App(props){
return <h1>{props.text}</h1>
}
export default App;
现在终于在 app.jsx 文件中,我尝试导入/请求 React 文件,但出现错误“未定义要求”
在控制台中导入 app.jsx 时,它说 require 没有定义 我正在使用导入,这就是它所说的
【问题讨论】:
-
尝试在import语句import App from "./components/App.jsx"中添加文件类型;
-
这能回答你的问题吗? importing React component file with node js
标签: javascript html node.js reactjs express