Simply remove the grouping (* as
) from your import statement:
import moment from 'moment';
Without digging too deeply in to the source code, it looks like moment
usually exports a function, that has all kinds of methods and other properties attached to it.
By using * as
, you're effectively grabbing all those properties and attaching them to a new object, destroying the original function. Instead, you just want the chief export (export default
in ES6, module.exports
object in Node.js).
Alternatively, you could do
import moment, * as moments from 'moment';
to get the moment function as moment
, and all the other properties on an object called moments
. This makes a little less sense when converting ES5 exports like this to ES6 style, because moment
will retain the same properties.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…