非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"; },