功能:我的信息
登录后,点tab页夹切换到“我的”,展示登陆者的信息。其本质其实和欢迎页面一个思路。
切换到我的tab时,onLoad读取缓存中的登录用户信息,然后再页面打印详细的用户信息
页面原型

1、my.js
Page({
data: {
student: {}
},
onLoad(options) {
var student = wx.getStorageSync('student')
this.setData({
student: student
})
console.log("数据:")
console.log(this.data.student)
}
})
2、my.wxml
<view>
<view class="container" style="background-image: url(/pages/images/mini_login_b_2.jpg);">
<view>
<view>编号:{{student.id}}</view>
<view>身份证号:{{student.idCard}}</view>
<view>姓名:{{student.name}}</view>
<view>性别:{{student.sex}}</view>
<view>年龄:{{student.age}}</view>
<view>地址:{{student.address}}</view>
</view>
</view>
</view>
3、my.wxss
page{
height: 100%;
}
.container{
height: 100vh;
}
此博客介绍了微信小程序中如何实现登录用户信息的显示,通过'onLoad'生命周期函数读取本地缓存的用户数据,并在页面上详细展示,包括编号、身份证号、姓名等个人信息。

被折叠的 条评论
为什么被折叠?



