Data: { openid:“dssafas” }, onLaunch: function () { var that = this; wx.login({ success: function (res) { var code = res.code; if (res.code) { wx.request({ url: ‘https://wxxcx.nbguohe.top/index.php/Wechat/login/getOpenid’, method: “get”, data: { code: code }, header: {}, success: function (res) { that.Data.openid=“ssss” }, fail: function (res) { }, complete: function (res) { }, }) } else { console.log(‘获取用户登录态失败!’) } } });
代码这样的,在其他页面输出,显示的还是最开始的dssafas