开始学习backbone.js

现在这水平也就能看到backbone.js的简单模板。。。

<!DOCTYPE html>
<html>
     <head>
         <script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
         <script src="http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.5.2/underscore-min.js"></script>
         <script src="http://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.0.0/backbone-min.js"></script>
     </head>
     <body>
         <div id="container">Loading...</div>
 
         <script type="text/template" id="who_template">
            <h3>Hello <%= who %></h3>
        </script>
     </body>
 </html>
  
 <script>
    var AppView = Backbone.View.extend({
        el: '#container',
        initialize: function(options) {
            this.render();
        },
        render: function() {
            var template = _.template(("#who_template").html());
            this.el.html(template({who: 'Backbone!'}));
        }
    });
 
    setTimeout(function(){
        var appView = new AppView();
    }, 1000);
</script>


大家觉得文章对你有些作用! 如果想赏钱,可以用微信扫描下面的二维码,感谢!
另外再次标注博客原地址  xiaorui.cc

发表评论

邮箱地址不会被公开。 必填项已用*标注