尝试创建Backbone模型并出错。我添加了jquery,下划线和主干但仍然有错误。
var Alco = Backbone.Model.extend({
defaults: {
price: 100,
name: "Vodka",
description: "I don't know",
img: "http://xo.kz/media/images/products/2016/02/i1g1_small_13.png"
}
});
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<link rel="stylesheet" href="css/mainstyle.css">
<script src="js/main.js" type="text/javascript"></script>
<title> AlcoWiki </title>
</head>
<body>
<script src="js/jquery-1.12.2.js" type="text/javascript"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.6.0/underscore-min.js"></script>
<script src="js/backbone.js" type="text/javascript"></script>
</body>
</html>
答案 0 :(得分:0)
如果所有引用的文件都存在并加载,那么这应该可以正常工作
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<link rel="stylesheet" href="css/mainstyle.css">
<title> AlcoWiki </title>
</head>
<body>
<script src="http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.6.0/underscore-min.js"></script>
<script src="js/backbone.js" type="text/javascript"></script>
<script src="js/main.js" type="text/javascript"></script>
</body>
</html>