未捕获的TypeError下划线-min.js

时间:2013-12-16 07:26:51

标签: javascript jquery backbone.js

我对骨干js很新。现在我试图为backbonejs创建一个示例程序。这是简单的骨干计划。但它不断显示这个错误。
    错误是“Uncaught TypeError underscore-min.js”我已经尝试了很多选项,比如重新安排库。但它不起作用..请帮帮我

<html>
    <head>
        <meta charset ="utf-8">
        <title>
                Sample Backbone Page
        </title>
    </head>
    <body>
        <div class = "page">

        </div>


    <script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/1.8.2/jquery.min.js" type="text/javascript"></script> 
    <script src="http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.4.2/underscore-min.js" type="text/javascript"></script> 
    <script src="http://cdnjs.cloudflare.com/ajax/libs/backbone.js/0.9.2/backbone-min.js"></script> 


<!--        <script src = "/jquery/jquery-min.js"></script>
        <script src = "/underscore/underscore-min.js"></script>
        <script src = "/backbone/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 a Backbone Page');
            });
            Backbone.History.Start();
        </script>

    </body>

</html>

..

1 个答案:

答案 0 :(得分:0)

Javascript区分大小写,因此该行会抛出错误:

Backbone.History.Start();

要修复它,只需将其更改为:

Backbone.history.start();

在文档中查看更多内容:http://backbonejs.org/#History-start

这是一个有效的演示:http://jsbin.com/oWEquYI/1/edit