小程序代码查看器

ai4444 带你拆解一个最小小程序的结构

app.js
20 行
1 // app.js
2 App({
3 onLaunch() {
4 // 展示本地存储能力
5 const logs = wx.getStorageSync('logs') || []
6 logs.unshift(Date.now())
7 wx.setStorageSync('logs', logs)
8
9 // 登录
10 wx.login({
11 success: res => {
12 // 发送 res.code 到后台换取 openId, sessionKey, unionId
13 }
14 })
15 },
16 globalData: {
17 userInfo: null
18 }
19 })
20