微信小程序

小程序

注册

https://mp.weixin.qq.com/cgi-bin/wx

登录

https://mp.weixin.qq.com/

开发工具

https://developers.weixin.qq.com/miniprogram/dev/devtools/download.html

开发文档

https://developers.weixin.qq.com/miniprogram/dev/framework/

微信开发者工具

app.js

全局js

//app.js
App({
  onLaunch: function () {
    console.log('app.js onLaunch-----------全局只执行一次')
  }
})

index.js

页面js

//index.js
const app = getApp()

console.log('index.js onPageLoad-----------即使没打开页面也会执行onPageLoad')

Page({
  onLoad: function () { console.log('index.js onLoad----------页面onload') },
  onShow: function () { console.log('index.js onShow----------页面显示时执行') },
  onReady: function () { console.log('index.js onReady----------页面渲染完毕') },
  onHide: function () { console.log('index.js onHide----------页面隐藏时执行') },
})

原文地址:https://www.cnblogs.com/aeolian/p/12118226.html