const setData = require('../../utils/processingData'); Component({ options: { addGlobalClass: true, }, /** * 组件的属性列表 */ properties: { /* 选择用户列表下标 */ userIndex: { type: Number, value: 0 } }, /** * 组件的初始数据 */ data: { userList: [], //用户列表 }, /* 组件的生命周期 */ lifetimes: { attached: function () { // 在组件实例进入页面节点树时执行 let list = wx.getStorageSync('account_list'); const userList = setData.imageType(list, "headportrait"), userIndex = (wx.getStorageSync('userData').index) ? wx.getStorageSync('userData').index : 0; this.setData({ userList, userIndex }); } }, /** * 组件的方法列表 */ methods: { /* 用户账号选择 */ userChange(e) { // console.log(e) const { index } = e.currentTarget.dataset; this.triggerEvent('userChange', { userIndex: index }) } } })