0
我得到這個錯誤:Momentjs棄用錯誤,不同的瀏覽器功能
Deprecation warning: value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are discouraged and will be removed in an upcoming major release. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info.
Arguments:
[0] _isAMomentObject: true, _isUTC: false, _useUTC: false, _l: undefined, _i: 1-June-2017, _f: undefined, _strict: undefined, _locale: [object Object]
Error
at Function.createFromInputFallback (http://localhost/client.min.js:46682:95)
at configFromString (http://localhost/client.min.js:48540:12)
at configFromInput (http://localhost/client.min.js:48909:10)
at prepareConfig (http://localhost/client.min.js:48892:10)
at createFromConfig (http://localhost/client.min.js:48859:41)
at createLocalOrUTC (http://localhost/client.min.js:48946:13)
at createLocal (http://localhost/client.min.js:48950:13)
at Moment.isBefore (http://localhost/client.min.js:49517:49)
at http://localhost/client.min.js:46163:87
at Array.map (native)
因爲代碼最小化,我看不出到底是什麼原因引起的,並有大量的代碼,但它可能在這兩種:
this.state = {
bookedDays: this.props.bookedDays,
today: this.props.value != "" ? moment.unix(this.props.value.substr(0, this.props.value.indexOf('|'))/1000) : moment(),
selectedFromDate: this.props.value != "" ? moment.unix(this.props.value.substr(0, this.props.value.indexOf('|'))/1000) : moment(),
selectedToDate: this.props.value != "" ? moment.unix(this.props.value.substr(this.props.value.indexOf('|')+1)/1000) : moment(),
whichDate: 0
};
var liClasses = classNames({
'whiteDate': this.state.whichDate == 0 && ((this.state.selectedFromDate.isBefore(date, 'day') && this.state.selectedToDate.isAfter(date, 'day')) || this.state.selectedFromDate.isSame(date, 'day') || this.state.selectedToDate.isSame(date, 'day'))
});
注意,代碼只能在Chrome中,正確填充類,火狐,IE和邊緣都似乎不喜歡它。
謝謝!它增加了修復它的時刻。對於這個修補程序的任何未來讀者,我也填補了一天,以確保它始終是兩個數字,如'01' – Wayneio
@Wayneio可能它不需要從「D」標記代表1-每月的第幾天,使用DD來分析2位數字的日期。 – VincenzoC