一、項目搭建:
*注意事項:node>=6 and npm>=5.2*
1、npx create-react-app hello-world
2、cd hello-world
3、npm start
二、components與props:
import React,{Component} from 'react';
import ReactDOM from 'react-dom';
1、方式一:
function Welcome(props){
return (<div>展示數據:{props.name}</div>)
}
2、方式二:
class Welcome extends Component{
constructor(props){
super(props)
}
render(){
return (
<div>
<span>展示數據{this.props.name}</span>
<span>展示數據2</span>
</div>
)
}
}
ReactDOM.render(<Welcome name="wqqq" />, document.getElementById('root'));