ReferenceError: Backbone is not defined - Attempting to use Parse.com Javascript SDK
ReferenceError: Backbone is not defined - Attempting to use Parse.com Javascript SDK
我正在尝试为一个学校项目构建一个网站、iOS 应用程序和 Android 应用程序,这需要我有一个服务器。我决定使用 Parse,因为它是免费的,而且我已经将它用于 iOS 应用程序。虽然,我没有使用 Parse 的 Javascript SDK 的经验。
问题:
我在我的 index.html 文件中 link 编辑了所有必需的库,但是当我启动该网站时,出现以下错误:
ReferenceError: Backbone is not defined.
问题:
是什么导致了这个错误?我该如何解决?
据我所知,SDK 是建立在 Backbone.js 之上的,我必须 Underscore.js linked 因为 Backbone.js 依赖于它?
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>TutorMe - Home</title>
<!-- Bootstrap -->
<link href="./bootstrap-3.3.5/css/bootstrap.min.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<link href="./css/index.css" rel="stylesheet">
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js"></script>
<script type="text/javascript" src="http://www.parsecdn.com/js/parse-1.5.0.min.js"></script>
</head>
<body>
<script type="text/javascript" src="./app/models/database.js"></script>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"> </script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="./bootstrap-3.3.5/js/bootstrap.min.js"></script>
</body>
</html>
database.js
Parse.initialize("X", "X");
var Student = Backbone.Model.extend({
});
var StudentList = Backbone.Collection.extend({
model: Student
});
var StudentListController = Backbone.View.extend({
initialize: function() {
}
});
编辑:
如果我 link backbone.js 我得到以下错误:
[Error] TypeError: undefined is not an object (evaluating 'i.extend')
(anonymous function) (backbone-min.js, line 1)
[Error] ReferenceError: Can't find variable: Backbone
global code (database.js, line 3)
代码:
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.2.2/backbone-min.js"></script>
您似乎没有链接您的 backbone.js
文件
<script src="/path/to/backbone.js"></script>
或链接到 cdn
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.2.2/backbone-min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.2.2/backbone-min.map"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.2.2/backbone.js"></script>
我正在尝试为一个学校项目构建一个网站、iOS 应用程序和 Android 应用程序,这需要我有一个服务器。我决定使用 Parse,因为它是免费的,而且我已经将它用于 iOS 应用程序。虽然,我没有使用 Parse 的 Javascript SDK 的经验。
问题:
我在我的 index.html 文件中 link 编辑了所有必需的库,但是当我启动该网站时,出现以下错误:
ReferenceError: Backbone is not defined.
问题:
是什么导致了这个错误?我该如何解决?
据我所知,SDK 是建立在 Backbone.js 之上的,我必须 Underscore.js linked 因为 Backbone.js 依赖于它?
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>TutorMe - Home</title>
<!-- Bootstrap -->
<link href="./bootstrap-3.3.5/css/bootstrap.min.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<link href="./css/index.css" rel="stylesheet">
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js"></script>
<script type="text/javascript" src="http://www.parsecdn.com/js/parse-1.5.0.min.js"></script>
</head>
<body>
<script type="text/javascript" src="./app/models/database.js"></script>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"> </script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="./bootstrap-3.3.5/js/bootstrap.min.js"></script>
</body>
</html>
database.js
Parse.initialize("X", "X");
var Student = Backbone.Model.extend({
});
var StudentList = Backbone.Collection.extend({
model: Student
});
var StudentListController = Backbone.View.extend({
initialize: function() {
}
});
编辑:
如果我 link backbone.js 我得到以下错误:
[Error] TypeError: undefined is not an object (evaluating 'i.extend')
(anonymous function) (backbone-min.js, line 1)
[Error] ReferenceError: Can't find variable: Backbone
global code (database.js, line 3)
代码:
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.2.2/backbone-min.js"></script>
您似乎没有链接您的 backbone.js
文件
<script src="/path/to/backbone.js"></script>
或链接到 cdn
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.2.2/backbone-min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.2.2/backbone-min.map"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.2.2/backbone.js"></script>