0
我想在使用ReactDOM渲染方法的主html文件上渲染一個簡單的div,但div並沒有渲染在屏幕上,也沒有拋出任何異常。我做錯了嗎?ReactDOM不渲染一個簡單的div
app.js:
import React from 'react';
import ReactDOM from 'react-dom';
ReactDOM.render(
<h1> Hi! </h1>, document.getElementById('root')
);
的index.html:
<!doctype html>
<html>
<head>
<title>Example</title>
</head>
<body>
<h1> Hello World! </h1>
<div id="root"></div>
</body>
</html>
屏幕只能顯示的 「Hello World!」 h1標籤。
我也使用webpack webpack開發服務器和Babel。
您還沒有''中index.html' app.js'文件 –