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中文网其它相关文章!
……