React 组件刷新

 时间:2024-10-11 23:23:33

1、检查react编写的页面在浏览器能否显示以下步骤不做详细讲解,不清楚的可看回我之前的经验。1.打包npm run build2.启动expressnpm run start3.浏览器输入地址127.0.0.1:9000

React 组件刷新

2、this.state小试牛刀1.编辑about.jsx2.添加以下代码:constructor(props){ super(props); this.state = {'name':'jack'};}render(){ return( <div>{this.state.name}</div> ) }

React 组件刷新React 组件刷新

3、验证打包,浏览器显示页面

React 组件刷新

4、通过button点击刷新组件内容1.编辑about.j衡痕贤伎sx2.添加以下代码:changeText(){ this.setState(撑俯擂摔{'name':'kate'}); console.log(this.state.name);}render(){ return( <div> <div><Button type="primary" onClick={this.changeText.bind(this)}>点击更改</Button></div> <div>{this.state.name}</div> </div> ) }

React 组件刷新

5、验证1.打包,浏览器显示页面2.点击按钮,可以看到组件的内容已变化

React 组件刷新React 组件刷新
  • 如何去身体里的湿气?
  • Windows firewall怎样停止Windows firewall服务
  • 营养美味健康的早餐——牛肉火腿炒饭
  • dnf合金战士天空套如何领取
  • 痛风患者的饮食指导
  • 热门搜索
    经典诵读手抄报 爱我中华手抄报 少先队员手抄报 感恩父母手抄报 节水手抄报简单又漂亮 春节英语手抄报 食品安全手抄报内容 平安校园手抄报 元宵节手抄报内容 三爱三节手抄报