react 运用 fetch 请求数据

曾经终败给现在 2022-02-27 05:42 381阅读 0赞
  1. componentDidMount(){
  2. fetch('服务器接口').then(res=>{
  3. if(res.ok){
  4. res.json().then(data=>{
  5. this.setState({
  6. data //ES6语法
  7. })
  8. })
  9. }
  10. })
  11. }

发表评论

表情:
评论列表 (有 0 条评论,381人围观)

还没有评论,来说两句吧...

相关阅读