react 运用 fetch 请求数据

componentDidMount(){
   fetch('服务器接口').then(res=>{
      if(res.ok){
         res.json().then(data=>{
             this.setState({
                 data     //ES6语法
             })
         })   
      }

   })
}

猜你喜欢

转载自blog.csdn.net/weixin_40802058/article/details/88831883
今日推荐