创建项目

执行命令

  1. npx create-react-app frontend
  2. cd frontend
  3. npm start

简化项目

src/index.js

  1. import React from 'react';
  2. import ReactDOM from 'react-dom';
  3. import App from './App';
  4. ReactDOM.render(
  5. <App />,
  6. document.getElementById('root')
  7. );

src/app.js

  1. function App() {
  2. return (
  3. <div>
  4. App
  5. </div>
  6. );
  7. }
  8. export default App;

public/index.html

  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1">
  6. <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
  7. <title>blog-v1</title>
  8. </head>
  9. <body>
  10. <div id="root"></div>
  11. </body>
  12. </html>

项目目录

  1. src
  2. |-components 公共组件
  3. |-pages 页面内容组件
  4. |-request 网络请求
  5. |-constants 常量
  6. |-store
  7. |--|-reducers
  8. |--|-store
  9. |-app.js 根组件
  10. |-index.js 入口文件