app

小程序运行环境定义了App()全局函数。

  1. App({
  2. onLaunch: function(options) {
  3. // Do something initial when launch.
  4. },
  5. onShow: function(options) {
  6. // Do something when show.
  7. },
  8. onHide: function() {
  9. // Do something when hide.
  10. },
  11. onError: function(msg) {
  12. console.log(msg)
  13. },
  14. globalData: 'I am global data'
  15. })

在其它文件里想得到这个类 getApp();