BackboneJS没有给出输出

时间:2014-05-09 13:18:24

标签: backbone.js

<html>
<head>
<meta charset="utf-8">
<title>BackboneJs</title>
<link  rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/2.1.1/css/bootstrap.min.css">
</head>
<body>
<div class="container">
<h1>Accounts Manager</h1>
<hr />
<div class="page"></div>
</div>
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js">
 </script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.6.0/underscore- min.js">   
</script> 
<script src="http://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.1.2/backbone-min.js">       
</script>

<script>
var Router = Backbone.Router.extend({

    routes: {

        '': "home"
    }

});

var router = new Router();
router.on('route: home', function(){
    console.log("We have loaded the home page");
});

Backbone.history.start();  

</script>
</body>
</html>
  

这里的所有内容似乎都是位置,控制台日志应该在控制台中提供输出,但页面上的标题正常,但控制台中的输出丢失,没有错误。

1 个答案:

答案 0 :(得分:0)

看起来你需要在家里听取路由器时删除空间

var router = new Router();
router.on('route:home', function(){
    console.log("We have loaded the home page");
});

http://jsfiddle.net/rHZWc/