如何解决预期令牌“ lt;”反应问题

发布于 2025-01-22 08:52:59 字数 765 浏览 3 评论 0原文

当我在下面编写代码时,我会收到此错误,预计“<”。 错误是指发布的代码的最后一行。 我回顾了几次代码,但找不到错误

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

灵芸 2025-01-29 08:52:59

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文