【发布时间】:2016-05-31 20:33:41
【问题描述】:
我有 isLeap 作为检查当前年份是否为闰年的道具和另一个道具 currentMonth 这是当前月份的计数。 (例如 1 代表 2 月)
当我尝试在函数或闭包中创建函数时,控制台抛出 "Unexpected token" 错误,如下所示
70 | },
71 | daysInMonth : function(d){
> 72 | var leapCase = function(this.props.isLeap){
| ^
73 | }
74 | },
75 | render : function(){
在渲染函数中,我通过组件的属性调用上述函数:
<Week key={i} dayCount = {this.daysInMonth(this.props.currentMonth)} />
【问题讨论】:
-
Unexpected token this? -
with
leapcase我正在尝试检查二月是否属于闰年。如果是,则返回 29,否则返回 28。
标签: javascript reactjs closures