react-03 first case

1 目录结构

 

 

 

2 index.js

/*
应用的入口组件:作用是渲染组件
* */

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

import App from './App'

//将App组件标签渲染到index页面的div上
ReactDOM .render(<App/>,document.getElementById('root'));

3 App.js

/*
应用的根组件
* */
import React,{Component} from 'react'

export default class App extends Component{

    //必须有render且必须返回一个DOM虚拟对象
    render(){
        return <div>App</div>
    }
}

4 public/index.html

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <meta name="theme-color" content="#000000" />
    <link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
    <title>React App</title>
  </head>
  <body>
    <noscript>You need to enable JavaScript to run this app.</noscript>
    <div id="root"></div>
  </body>
</html>
发布了49 篇原创文章 · 获赞 13 · 访问量 3万+

猜你喜欢

转载自blog.csdn.net/mengdeng19950715/article/details/98732057