network/request.jsajax
//封裝ajax請求 const http = (url,type,parameter) => { return new Promise((resolve,reject) => { wx.request({ url:url, method:type, success:function (res) { resolve(res.data); }, fail:function (err) { reject(err) } }) }) } export {http}
在index.wpy中使用微信
import { http } from '../network/request'; http("https://easy-mock.com/mock/5cc66aee7a9a541c744c9c07/example/restful/:id/list","GET").then(function (res) { console.log(res) }).catch(function (err) { });
個人微信公衆號:天字一等restful