React JS index.js文件如何联系index.html以获取ID引用?\[重复\]

reactjs React.js

Eva西里蛋蛋

2020-03-16

我最近开始做出反应。

我的index.html包含

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
    <title>React App</title>
  </head>
  <body>
    <div id="root"></div>
  </body>
</html>

index.js包含

import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import './index.css';

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

我的疑问是我没有index.js在中的任何脚本标签中提及index.html但是它如何引用rootin中div元素index.html我想知道它工作正常。请给我解释一下。

我已经运行了这些命令来创建应用程序

npm install -g create-react-app
create-react-app hello-world
cd hello-world
npm start

第1792篇《React JS index.js文件如何联系index.html以获取ID引用?\[重复\]》来自Winter(https://github.com/aiyld/aiyld.github.io)的站点

0个回答

问题类别

JavaScript Ckeditor Python Webpack TypeScript Vue.js React.js ExpressJS KoaJS CSS Node.js HTML Django 单元测试 PHP Asp.net jQuery Bootstrap IOS Android