2019-01-03 访问数据

react获取服务器api接口:react中没有提供专门的请求数据的模块,但是我们可以shying任何第三方请求数据模块实现请求数据。

1. Axios (https://github.com/axios/axios axios的作者觉得jsonp不太友好,推荐用CORS方式更为干净(后端运行跨域))

a)首先需要安装axios模块 

npm install axios --save 

b) 引用axios

c)直接调用方法


2.FetchJsonp(只支持get方法)

a) 安装模块: npm install fetch-jsonp --save

b)引用

c)直接调用


你可能感兴趣的:(2019-01-03 访问数据)