[英]Error when replacing Moment.js with Luxon in Google Apps Script
I have a Google Apps script that uses Moment.js that I want to use Luxon instead.我有一个使用 Moment.js 的 Google Apps 脚本,我想改用 Luxon。 The following worked fine for using moment.js:
以下适用于使用 moment.js:
eval(UrlFetchApp.fetch('https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment-with-locales.js').getContentText());
However, eplacing the URL with the CDN URL of Luxon like so:但是,将 URL 替换为 Luxon 的 CDN URL,如下所示:
eval(UrlFetchApp.fetch('https://cdn.jsdelivr.net/npm/luxon@3.0.3/build/global/luxon.min.js').getContentText());
Throws an error:引发错误:
console.log(DateTime.now().toString());
ReferenceError: DateTime is not defined
Copying the minified file to luxon.gs also fails with the same error.将缩小文件复制到 luxon.gs 也会失败并出现相同的错误。
I have no idea if the problem is with something that changed in Luxon or a limitation of Apps Script — any ideas?我不知道问题是出在 Luxon 中的某些更改还是 Apps 脚本的限制 - 有什么想法吗?
I copied the entire Luxon.js (non-minified) library into a.gs file and was able to use it:我将整个 Luxon.js(非缩小)库复制到 a.gs 文件中并且能够使用它:
console.log(luxon.DateTime.now().toLocaleString());
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.