import React from 'react'; import ReactDOM from 'react-dom'; import fetchJsonp from 'fetch-jsonp'; class App extends React.Component{ state ={ isLoading:false, data:null }; fetchData = async() =>{ fetchJsonp('https://sp0.baidu.com/5a1Fazu8AA54nxGko9WTAnF6hhy/su?wd=a',{ jsonpCallback:'cb' }).then(res=>{ return res.json(); }).then(data=>{ console.log(data); }) }; render(){ let {isLoading, data} = this.state; return (

fetch-jsonp跨域取数据

{ isLoading?加载中...:
{ data==null?暂无数据...:
  • 名字: {data.name}
  • 公司网址: {data.company}
  • 头像:
}
}
) } } ReactDOM.render( , document.getElementById('root'));