如何解决预期令牌“ lt;”反应问题
当我在下面编写代码时,我会收到此错误,预计“<”。 错误是指发布的代码的最后一行。 我回顾了几次代码,但找不到错误
import React from "react";
export default function Navbar(){
return <h1>Place for Navbar</h1>
}
import React from "react";
export default function Main(){
return <h1>Place for Main</h1>
}
import React from "react";
import Navbar from "../componenets/Navbar";
import Main from "../componenets/Main";
export default function App(){
return (
<div className="container">
<Navbar />
<Main />
</div>
)
}
import React from "react";
import ReactDOM from "react-dom";
import App from "./App";
ReactDOM.render(
<App />, document.querySelector(".root")
)
When I write the code below , I receive this error, that is expected "<".
The error refers for the last line of posted code.
I reviewed code couple times but cannot find error
import React from "react";
export default function Navbar(){
return <h1>Place for Navbar</h1>
}
import React from "react";
export default function Main(){
return <h1>Place for Main</h1>
}
import React from "react";
import Navbar from "../componenets/Navbar";
import Main from "../componenets/Main";
export default function App(){
return (
<div className="container">
<Navbar />
<Main />
</div>
)
}
import React from "react";
import ReactDOM from "react-dom";
import App from "./App";
ReactDOM.render(
<App />, document.querySelector(".root")
)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
JSX语法在JavaScript中不支持。在将其发送到浏览器之前,您需要将其转移到JS中。
这通常是使用webpack完成的,但可以使用其他工具。
React文档具有a 建立React Project的指南这包括设置合适的工具链。
JSX syntax is not supported in JavaScript. You need to transpile it into JS before sending it to the browser.
This is usually done using Webpack but other tools are available.
The React documentation has a guide to setting up a React project that includes setting up a suitable toolchain. MDN has it's own version.