//登入頁面
Page({
data:{
username:'',
password:''
}, onShareAppMessage: function () {
#return {
title: '登入',
desc: '登入頁面!'
}
},
onShow:function(){
var that=this;
wx.getStorage( {
key: 'username',
success: function(res) {
console.log(res.data)
that.setData( {
username: res.data
})
},
})
wx.getStorage({
key: 'password',
success: function (res) {
console.log(res.data)
#that.setData({
password: res.data
})
}
#})
},
//app.js
App({
onLaunch: function() {
//呼叫API從本機快取取得資料
var logs = wx.getStorageSync('logs') || []
logs.unshift(Date.now())
wx.setStorageSync('logs', logs)
},
getUserInfo: function(cb) {
var that = this
if (this.globalData .userInfo) {
typeof cb == "function" && cb(this.globalData.userInfo)
} else {
//呼叫登入介面
wx.getUserInfo({
withCredentials: false,
success: function(res) {
that.globalData.userInfo = res.userInfo
#typeof cb == "function" && cb(that.globalData.userInfo)
#}
})
}
},
globalData: {
#userInfo: null
},
})
以上是如何將其他頁面的資料存入app.js中的詳細內容。更多資訊請關注PHP中文網其他相關文章!