gpt4 book ai didi

javascript - 全局属性的影子 'undefined'

转载 作者:行者123 更新时间:2023-12-01 01:16:03 24 4
gpt4 key购买 nike

任何人都可以给我一些关于修复 JSLint 收到的警告的指示吗?

我有以下代码:

/* global window, define, module */
(function(global, factory) {
var Gauge = factory(global);
if(typeof define === "function" && define.amd) {
// AMD support
define(function() {return Gauge;});
}else if(typeof module === "object" && module.exports) {
// CommonJS support
module.exports = Gauge;
}else {
// We are probably running in the browser
global.Gauge = Gauge;
}
})(typeof window === "undefined" ? this : window, function(global, undefined) {

在最后一行(typeof window === "undefined"... 我收到此警告:

Line 14: Shadowing of global property 'undefined' no-shadow-restricted-names

如果可能的话,我想消除这个警告。

最佳答案

您可能需要从 the function(global, undefined) { function 中删除 undefined 参数。 ,或禁用该特定行上的警告(因为它可以防止其他脚本未能注意到此警告)。或者,使用构建系统自动将此 UMD header 添加到您的模块中,并仅在源代码上运行 jslint。

关于javascript - 全局属性的影子 'undefined',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54750923/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com