【发布时间】:2017-07-15 17:11:57
【问题描述】:
我有一个应用程序在前端的 Backbone 上运行,当浏览器加载页面时,它会在控制台中返回错误:
Uncaught ReferenceError: app is not defined
at index.js:6
at index.js:51
(anonymous) @ index.js:6
(anonymous) @ index.js:51
index.js
/* global app:true */
(function() {
'use strict';
app = app || {}; // error here although it must prevent of undefined
// variables stay undefined
//.......
//backbone code here
//.......
$(document).ready(function() {
app.contactView = new app.ContactView(); //error here
});
}());
从构建切换到 CDN 或进入 Backbone.Model 属性返回相同的错误。
【问题讨论】:
标签: javascript namespaces javascript-namespaces