参考错误:未定义时刻(使用 moment.js) [英] Reference Error: moment is not defined (Using moment.js)

查看:87
本文介绍了参考错误:未定义时刻(使用 moment.js)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我安装了 moment.js 库,正准备尝试一下,但出现此错误时.我尝试了很多不同的东西,但没有任何效果.有什么想法吗?

I installed the moment.js library and was about to play around with it a little bit, when i got this error. I've tried many different things, but nothing has worked. Any ideas?

我有一个文件夹,我已经将 moment.js 安装到(npm install moment)中,并且我正在运行我的程序(节点 isDate.js).

I have a folder that i've installed moment.js into (npm install moment) and i'm running my program (node isDate.js).

import {moment} from 'moment';

function isDate(string) {
    {
        moment(string).format(["MM-DD-YYYY", "YYYY-MM-DD"]);
    }
} exports.isDate = isDate;

参考错误:未定义时刻

推荐答案

根据 Aleks 评论

As per Aleks comment

const moment= require('moment') 

为我工作.

这篇关于参考错误:未定义时刻(使用 moment.js)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆