//Tips:每个页面级的组件第一行必须加
import React from 'react'
1.无状态组件
//就是一个函数,无状态组件中不能写事件,不能对
import React from 'react';
function App() {
return (
<div className="App" >
hello world
</div>
);
}
export default App;
2.有状态组件
有状态组件要写在render中
import React from 'react';
class App extends React.Component{
//数据放在构造函数的state属性中
constructor(props){
super(props);
this.state={
msg:"hello world"
}
}
render(){
return(
//使用数据 {this.state.msg}
<div>{this.state.msg}</div>
)
}
}
export default App;