1 使用 Npm 下载 axios npm install --save axios
- var update_url = axios.create({baseURL:'debug url'});
- update_url.get('/debug url').then(function (response){
- //response 就是请求 url 返回的内容
- }
上述的方法请求文件时候, body 的默认格式不是 form-data 因此我们需要请求的数据格式为 form-data 的时候, 需要使用下面的库 request
npm install --save request
2request 请求 url, 可以使用 get,post 的方式.
- request.post({url:'http://192.168.1.159/backup/client/interface1s.php?func=getMusicPath',formData:{musicname:task.name}},function optionalCallback(err,httpResponse,body){
- //body 为 url 反馈回来的数据,
- }
来源: http://www.jb51.net/article/135917.htm