微信小程序开发 - 修改globalData的值

非app.js的页面:
var app = getApp();
app.globalData.userName = "xxx";
app.js:

在onLaunch函数中:(var that = this;必须写在onlaunch()开始)

onLaunch: function () {
    var that = this;
    that.globalData.userName = "xxx";
  },

你可能感兴趣的:(微信小程序,微信小程序开发)