[email protected] month selection bug fix

background

Company development framework using angular5, in order to improve development efficiency, the ng-zorro-antdintroduction of project library. During development, it was found in January to select the library in question ( ng-Zorro's official website can be reproduced), specific performance is as follows:

Bug Pictures

As can be seen from the chart, select the month, there were two in March , two in May , two in December . This bug only appears in the selected month, even if the date is selected, or you can choose the month, there is still this bug.

The reason bug generated

Look at the ng-zorro-antdsource code, it is found to generate a list of the month, when the month calculation error. FIG related code is as follows:

Bug Pictures

The idea developers should be, by setMonth()acquiring time each month to turn. The problem is precisely here. If the current is Wed Jul 31 2019 18:00:00 GMT+0800 (中国标准时间)then generated data for January ( setMonth(0)) no problem is Thu Jan 31 2019 18:00:00 GMT+0800 (中国标准时间), but the resulting data in February ( setMonth(1)) when back problems, since February has only 28 days, therefore, the results of the code is Sun Mar 03 2019 18:00:00 GMT+0800 (中国标准时间), in fact, already March of.

That is, the number 29,30,31 month, month selector controls can be stable reproduce the bug.

Solve bug

Node_modules found in the ng-zorro-antdfolder, open it ems5 antd.js file folder under under, modify 14387,14388 and 14423 lines of code related. As shown below:

Bug Pictures

Bug Pictures

Restart project resolves the bug.


In the latest version [email protected], the bug has been resolved.

Guess you like

Origin blog.51cto.com/13876655/2425392