Component({ properties: { list: { type: Array }, callback: { type: Function } }, data: { safeAreaBot: 0, show: false, showList: [], extend: [] }, lifetimes: { attached: function () { wx.getSystemInfo({ success: res => { this.setData({ safeAreaBot: res.screenHeight - res.safeArea.bottom }) } }) getApp().globalData.Language.getLanguagePackage(this) }, }, observers: { 'list': function (numberA, numberB) { numberA = numberA.map(v => { v.classnames = (v.icon.split("-")[0] == 'color' ? 't-icon ' : 'iconfont ') + v.icon console.log(v.classnames) return v }) if (numberA.length >= 5) { let showList = numberA.splice(0, 3); showList.push({ classnames: "t-icon color-gengduo", icon: "color-gengduo", label: "更多" }) this.setData({ showList, extend: numberA }) } else { this.setData({ showList: numberA }) } } }, options: { addGlobalClass: true }, methods: { onClose() { this.setData({ show: false }) }, callback(e) { const { item } = e.currentTarget.dataset; if (item.label == '更多') return this.setData({ show: true }) if (this.data.show) this.setData({ show: false }) if (!item) return; this.triggerEvent("callback", item) } } })