我正在嘗試爲學校項目構建網站,iOS應用和Android應用,這需要我有一臺服務器。我決定使用Parse,因爲它是免費的,我已經將它用於iOS應用程序。雖然,我沒有使用Parse的Javascript SDK的經驗。ReferenceError:骨幹未定義 - 嘗試使用Parse.com Javascript SDK
問題:
我已經鏈接的所有需要的庫在我的index.html文件,但是當我啓動了網站,我收到以下錯誤:
ReferenceError: Backbone is not defined.
問:
是什麼導致這個錯誤?我該如何解決它?
從我讀過的SDK構建在Backbone.js之上,我必須鏈接Underscore.js,因爲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() {
}
});
編輯:
如果我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>
強調JS,卻忘了骨幹JS在你提供的代碼中。 –
@JSantosh,當我鏈接主幹時,我得到另一個錯誤以及原始錯誤。請看我更新的問題。 – Jonathan