var page = { data: { textList: [], }, onShow: function(e) { this.getData() }, getData() { wx.request({ // url: 'https://mp-test.kingsome.cn/api/open/zp/text', //开发者服务器接口地址", url: 'http://localhost:2333/api/open/zp/text', //开发者服务器接口地址", data: 'data', //请求的参数", method: 'GET', dataType: 'json', //如果设为json,会尝试对返回的数据做一次 JSON.parse success: res => { const data = res.data if (data.errcode === 0) { const textList = data.result this.setData({ textList: textList, }) } else { wx.showToast({ title: data.errmsg, //提示的内容, icon: 'fail', //图标, }) } }, fail: () => { wx.showToast({ title: '获取数据时出错!', //提示的内容, icon: 'fail', //图标, }) }, }) }, goDetails(e) { const _id = e.target.dataset.id wx.navigateTo({ url: `/pages/index/index?_id=${_id}`, }) }, } Page(page)