按照aboutfunction中的建议,我尝试使用空 Package 器〈〉...〈/〉 Package 器,但错误被作为〈〉的意外标记抛出..请帮助解决错误
const rootx = ReactDOM.createRoot(document.getElementById('Abt'));
const element5 = <AboutPage />;
rootx.render(element5);
function AboutPage() {
return (
<>
<h1>About</h1>
<p>Hello there.<br />How do you do?</p>
</>
);
}
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Add React in One Minute</title>
</head>
<body>
<h2>Add React in One Minute</h2>
<!-- We will put our React component inside this div. -->
<link rel="icon" type="./x-icon" href="./favicon.ico">
<div id="Abt"></div>
<!-- Load React. -->
<!-- Note: when deploying, replace "development.js" with "production.min.js". -->
<script src="https://unpkg.com/react@18/umd/react.development.js" crossorigin></script>
<script src="https://unpkg.com/react-dom@18/umd/react-dom.development.js" crossorigin></script>
<!-- Load your React component. -->
<script type="module" src="lik.js"></script>
</body>
</html>
1条答案
按热度按时间jpfvwuh41#
新版本的巴别塔可以通过巴别塔版本更新的第2步进行更新
npm安装@巴伯尔/cli@7巴伯尔-预设-React-应用程序@10
并更新了新的JSX预处理器命令:
npx babel--监视源--输出目录--预设babel-预设-React-应用程序/产品
这将允许空〈〉..〈/〉编译和呈现(随附屏幕截图)