@52fhy
        
        2016-01-22T08:23:16.000000Z
        字数 975
        阅读 457
    backbone
<!DOCTYPE html><head><meta charset="utf-8"><title>title</title><script src="http://the5fireblog.b0.upaiyun.com/staticfile/jquery-1.10.2.js"></script><script src="http://the5fireblog.b0.upaiyun.com/staticfile/underscore.js"></script><script src="http://the5fireblog.b0.upaiyun.com/staticfile/backbone.js"></script></head><body><script>var Man = Backbone.Model.extend({initialize: function(options){console.log('Hey '+ options.name +', you create me!');},//默认属性defaults: {name:'张三',age: '38'},//添加方法test: function(){return "我叫"+this.get('name')+",年方"+ this.get('age');}});var man = new Man({"name":"yjc"});//获取默认属性console.log(man.get('name'));console.log(man.get('age'));//设置属性man.set({"name":"yjc", "age":'22'});console.log(man.get('name'));console.log(man.get('age'));//调用自定义方法var r = man.test();console.log(r);</script></body>
参考:
1、the5fire/backbonejs-learning-note
https://github.com/the5fire/backbonejs-learning-note
2、Backbone.js API中文文档
http://www.css88.com/doc/backbone/
