我按照facebook的教程学习反应 . 我用 npm create-react-app 创建了一个反应应用程序 . Html文件位于名为public的文件夹中 . JS和CSS文件位于名为src的文件夹中 .
这是我 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>
<a href="login.html">Link</a>
<div id="root"></div>
</body>
</html>
这是我的 index.js :
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
ReactDOM.render(
<App name="Sumanth Jois"/>,
document.getElementById('root')
);
index.html工作正常 . <App/>
正在渲染到屏幕上 . 我有另一个文件login.html .
这是 login.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="app"></div>
</body>
</html>
这是我的 login.js :
import React from 'react';
import ReactDOM from 'react-dom';
ReactDOM.render(
<App name="Sumanth Jois"/>,
document.getElementById('app')
);
但是这次login.html没有显示任何空白 . 有人可以告诉我哪里出错了吗?我现在坚持了几个小时 .