1.profile.wxml主要
```
< button open - type = "getUserInfo"bindgetuserinfo = "onGotUserInfo" > 獲取用戶信息 < /button>
```
完整代碼:
```
< !--pages / profile / profile.wxml--><view class = 'profile' > <view class = "profile-img" > <open - data type = "userAvatarUrl" > </open-data>
</view > <open - data type = "userNickName"class = "profile-name" > </open-data>
</view > <button open - type = "getUserInfo"bindgetuserinfo = "onGotUserInfo" > 獲取用戶信息 < /button>/
```
2.profile.js主要
```
onGotUserInfo: function(event) {
console.log(event);
},
```
完整代碼
```
// pages/profile/profile.js
Page({
/**
* 頁面的初始數據
*/
data: {
},
onGotUserInfo: function(event) {
console.log(event);
},
/**
* 生命周期函數--監聽頁面加載
*/
onLoad: function(options) {
},
/**
* 生命周期函數--監聽頁面初次渲染完成
*/
onReady: function() {
},
/**
* 生命周期函數--監聽頁面顯示
*/
onShow: function() {
},
/**
* 生命周期函數--監聽頁面隱藏
*/
onHide: function() {
},
/**
* 生命周期函數--監聽頁面卸載
*/
onUnload: function() {
},
/**
* 頁面相關事件處理函數--監聽用戶下拉動作
*/
onPullDownRefresh: function() {
},
/**
* 頁面上拉觸底事件的處理函數
*/
onReachBottom: function() {
},
/**
* 用戶點擊右上角分享
*/
onShareAppMessage: function() {
}
})
```
效果截圖:

