data: { formatter:function(day) { //此地方注意一下 请求接口格式化数据时,处理请求一次 return day; } }, /** * 获取当月的签到数据 */ getMonthSignInData(){ const _this = this network.getRequestLoading(config.getMonthSignInData,{year:_this.data.cur_year,month:_this.data.cur_month}, "正在获取签到数据...", function (res) { _this.setData({ signInList:res, // 签到状态格式化 formatter: function(day){ //...数据处理 if(day.date<=new Date()){ if (_this.equalOneDay(day.date,new Date())){ day.text = '今天'; }else{ if (_this.getDaySignInStatus(day.date)) { //已签到 day.topInfo = '●'; } else if (!_this.getDaySignInStatus(day.date)) { //签到异常 day.bottomInfo = '●'; } } } return day } }) },
vant 自定义日期文案 怎么动态的传值进去?这里面的值 formatter 应该 怎么动态的 传入进去? 有大佬知道吗? [图片] Page({ data: { formatter(day) { const month = day.date.getMonth() + 1; const date = day.date.getDate(); if (month === 5) { if (date === 1) { day.topInfo = '劳动节'; } else if (date === 4) { day.topInfo = '五四青年节'; } else if (date === 11) { day.text = '今天'; } } if (day.type === 'start') { day.bottomInfo = '入住'; } else if (day.type === 'end') { day.bottomInfo = '离店'; } return day; }, }, });
2020-08-31