var month = now.getMonth() + 1;为什么要加1

同上
2025-03-04 11:51:04
推荐回答(1个)
回答1:

因为在javascript中now取出的month比实际的月份小1,就好像数组的第一个元素下标是0一样,在实际使用的时候需要加上1