// components/My_navBar/index.js Component({ /** * 组件的属性列表 */ options: { addGlobalClass: true }, properties: { }, lifetimes: { ready: function () { // 在组件实例进入页面节点树时执行 //获取当前登录用户名 const that = this; setTimeout(() => { let data = getApp().globalData.account_list[wx.getStorageSync('userData').index]; let userName = ''; (data.fbrand != null && data.fbrand != undefined) ? userName = data.fbrand + '-': userName = data.fname + '-' userName += data.frole; console.log(userName) that.setData({ userName }) }, 300) }, detached: function () { // 在组件实例被从页面节点树移除时执行 }, }, /** * 组件的初始数据 */ data: { userName: "", //用户名 NavHeight: getApp().globalData.myNavBorHeight, //头部导航高度 capsule: wx.getMenuButtonBoundingClientRect(), //胶囊位置 }, /** * 组件的方法列表 */ methods: { a1212() { //跳转到选择账号 wx.navigateTo({ url: '/pages/login/index?type=changeUser', }) } } })