Component({ /** * 组件的属性列表 */ properties: { receiveData: { type: null, observer: function (newVal, oldVal) { // let gradeText = '一年级' // switch (newVal.grade) { // case 'PRESCHOOL': // gradeText = '学前班'; // break; // case 'PRIMARY_FIRST_GRADE': // gradeText = '一年级'; // break; // case 'PRIMARY_SECOND_GRADE': // gradeText = '二年级'; // break; // case 'PRIMARY_THREE_GRADE': // gradeText = '三年级'; // break; // } this.setData({ isshowbtn: newVal.isshowbtn, //是否显示按钮 title: newVal.title, //标题 // grade: gradeText }) } }, grade: { type: 'String', observer: function (newVal) { console.log('年级', newVal) let gradeText = '一年级' switch (newVal) { case 'PRESCHOOL': gradeText = '学前班'; break; case 'PRIMARY_FIRST_GRADE': gradeText = '一年级'; break; case 'PRIMARY_SECOND_GRADE': gradeText = '二年级'; break; case 'PRIMARY_THREE_GRADE': gradeText = '三年级'; break; case 'PRIMARY_SENIOR_GRADE': gradeText = '四年级'; break; } this.setData({ gradeText: gradeText }) } } }, /** * 组件的初始数据 */ data: { statusBarHeight: getApp().globalData.statusBarHeight }, /** * 组件的方法列表 */ methods: { //点击年级 gradeTap: function () { console.log("点击年级"); this.triggerEvent('gradeTap', 'false'); console.log('状态栏高度', this.data.statusBarHeight) }, prePageTap: function () { console.log('点击返回') wx.navigateBack({ delta: 1 }) } } })