Component({ properties: { visible: { type: Boolean, value: false }, classList: { type: Array, value: [] } }, data: { selectedClassName: '' }, methods: { selectClass(e) { this.setData({ selectedClassName: e.currentTarget.dataset.name }); }, confirmSelection() { if (this.data.selectedClassName) { this.triggerEvent('confirm', { className: this.data.selectedClassName }); this.setData({ visible: false }); // 隐藏弹窗 } else { wx.showToast({ title: '请选择班级', icon: 'none' }); } }, cancelSelection() { this.setData({ visible: false }); // 隐藏弹窗 this.triggerEvent('cancel'); // 可选:触发取消事件 } } });