wx.request({ url: app.globalData.siteBaseUrl +'/goods/listGoods', method: "GET", data: {}, success: function (res) { var list = res.data.goodsList; if (list == null) { var toastText = "获取信息失败" + res.data.errMsg; wx.showToast({ title: toastText, icon: "", duration: 2000 });
时间: 2023-12-06 13:40:41 浏览: 32
这是一个使用微信小程序框架的 HTTP 请求示例,请求的 API 是 `/goods/listGoods`,请求方法是 GET,请求数据为空。成功获取到数据后会将结果赋值给变量 `list`,如果 `list` 为空,则会显示提示信息。提示信息使用了微信小程序的 `showToast` 方法,显示时间为 2 秒。
相关推荐
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![gz](https://img-home.csdnimg.cn/images/20210720083447.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)