如何获取index.html和index.js在Mac上的MAMP中呈现?

问题描述 投票:-1回答:1

我正在尝试使用http://localhost:8888/(MAMP)在htdocs中呈现我的index.html和index.js文件

index.js:

import React from 'react';
import ReactDOM from 'react-dom';

ReactDOM.render(<p>Hello</p>, document.getElementById('root'));

index.html:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport"
      content="width=device-width, initial-scale=1" />
    <title>React App</title>
  </head>
  <body>

    <div id="root"></div>

  </body>
</html>

我以为它们应该通过'root'连接,并显示'Hello',但不是,它只显示白屏。

请让我知道我在做什么错

html node.js reactjs localhost mamp
1个回答
-2
投票

我对React不太熟悉,但是我需要先使用NPM编译代码,然后在文件夹“ MY_NEW_APP”中使用已编译的代码。

也许此链接会为您提供帮助:medium.com/dailyjs/buiding-a-react

© www.soinside.com 2019 - 2024. All rights reserved.