[英]Cannot read property 'tz' of undefined in moment.js
JS JS
<script type="text/javascript" src="moment_timezone.js"/>
<script type="text/javascript" src="moment_timezone_data_2010_2020.js"/>
console.log(moment().tz("America/Los_Angeles").format());
Error is show Cannot read property 'tz' of undefined in moment_timezone.js .错误显示无法读取 moment_timezone.js 中未定义的属性“tz”。 i want to use moment js for converting time for diffrrent time zone .我想使用时刻 js 来转换不同时区的时间。
To fix the error you must import the library as follows:要修复错误,您必须按如下方式导入库:
'import timezone from 'moment-timezone'
Because moment-timezone uses below momentjs it is not necessary to import as such moment.因为 moment-timezone 在 momentjs 下面使用,所以没有必要导入这样的时刻。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.