我是backbone.js 的新手,正在编写我的第一个路由器。我有一个如下的骨干路由器,
<html lang="en" class="no-js">
<head>
<meta charset="utf-8">
<title>My First Backbone Tutorial</title>
<meta name="author" content="David Goodlad <david@goodlad.ca>">
<link rel="stylesheet" href="style/screen.css" media="screen, projection">
<link rel="stylesheet" href="style/fancypants.css" media="screen, projection">
<script type="text/template" id="library-template">
<h1> Music Library</h1>
<ul class="albums"></ul>
</script>
<script type="text/template" id="album-template">
<span class="album-title"><%= title %></span>
<span class="artist-name"><%= artist %></span>
<ol class="tracks">
<% _.each(tracks, function(track) { %>
<li><%= track.title %></li>
<% }); %>
</ol>
</script>
</head>
<body>
<div id="container">
<h1>User manager</h1>
<hr />
<div class="page"></div>
</div>
<script src="js/vendor/jquery-1.5.1.min.js"></script>
<script src="js/vendor/underscore.js"></script>
<script src="js/vendor/backbone.js"></script>
<script>
var Router = Backbone.Router.extend({
routes:{
"" : 'home'
}
});
var router = new Router();
router.on('route:home', function(){
console.log("======================================")
});
Backbone.history.start();
</script>
</body>
</html>
当我加载页面时,我在萤火虫中遇到错误,例如
TypeError: router.on 不是函数 router.on('route:home', function(){
我可以知道我的错误是什么。
提前致谢。