为什么 jshint 会警告 gConfiguration 未定义?我在函数开始之前定义了它。我也试着把它放在里面。我知道我可以在配置中将它声明为全局变量,但我不明白这是怎么回事?requirejs 在其声明的顶部使用了类似的模式。
/*jshint strict:true, undef:true */
/*global Backbone: true, $: true */
var gConfiguraton;
(function (global) {
'use strict';
var MYAPP = global.MYAPP = {};
MYAPP.version = '0.0.1';
// Defaults
MYAPP.settings = {
// Authorization
authorizationKey: null,
authorizationTokenType: 'Bearer',
authorizationTimestamp: null,
// Proxy
proxyUrl: null
};
// Depend on jQuery and Backbone
if (typeof $ !== 'undefined' && typeof Backbone !== 'undefined') {
// Look for global configuration provided by user and merge their settings
if (typeof gConfiguration !== 'undefined') {
$.extend(MYAPP.settings, gConfiguration);
}
MYAPP.Events = $.extend({}, Backbone.Events);
}
} (this));