[英]Moment.js: Uncaught TypeError: Cannot read property 'defineLocale' of undefined at moment.js:13
[英]Cannot read property 'tz' of undefined in moment.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());
錯誤顯示無法讀取 moment_timezone.js 中未定義的屬性“tz”。 我想使用時刻 js 來轉換不同時區的時間。
您需要在moment.js
之前包含moment_timezone.js
要修復錯誤,您必須按如下方式導入庫:
'import timezone from 'moment-timezone'
因為 moment-timezone 在 momentjs 下面使用,所以沒有必要導入這樣的時刻。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.