本文共 833 字,大约阅读时间需要 2 分钟。
针对微信小程序的A页面,有A.js、A.json、A.wxml、A.wxss四个文件,需在A.js中获取服务器数据库中的数据并存储到数组变量中,以便A.wxml调用其值。
服务器是一个存储空间,可通过HTTP地址访问,如阿里云、腾讯云等平台。大约100元起步价,适合存储后端文件和数据。
服务器通常附带数据库,例如阿里云选宝塔镜像,可用phpMyAdmin管理。后端文件可直接访问相绑数据库。
微信小程序点击按钮触发js事件,通过wx.request调用服务器文件,据服务器数据库执行增删改查。
onLoad: function (options) { var that = this; wx.request({ url: 'http://47.103.21.63/jnSelfPick/php/req_postList.php', data: { openid: '1234567890' }, method: 'GET', header: { 'content-type': 'application/json' }, success: function(res) { that.setData({ postList: res.data }); }, fail: function(res) { wx.showModal({ title: '提示', content: res.data }); } });}, 转载地址:http://rpzaz.baihongyu.com/