Why is moment js not working in mounted vue component?

Viewed 11494

When I put moment on the method like this:

<template> 
    ...
</template>
<script>
    export default{
        ...
        methods:{
            ...
            add(event){
                let current = moment()                  
            }
        }
    }
</script>

and then call the add method, it works without error.

But if I put moment on the mounted like this:

mounted(){
   let currentAt = moment()   
}

it does not work. It returns the following error:

[Vue warn]: Error in mounted hook: "ReferenceError: moment is not defined"

How can I solve this?

2 Answers
Related