backbone.js第一个例子

本文概述

  • 其次, 你需要添加Backbone.js库
  • 添加JavaScript文件
  • 第一个Backbone.js示例
【backbone.js第一个例子】Backbone.js应用程序是HTML和JavaScript的混合体。你需要的第一件事是HTML页面。
< !DOCTYPE html> < html> < head> . . < /head> < body> . . < /body> < /html>

其次,你需要添加Backbone.js库
< script src="http://img.readke.com/220416/010Pa614-0.jpg" type="text/javascript">< /script> < script src="http://img.readke.com/220416/010P93S9-1.jpg" type="text/javascript">< /script> < script src="http://img.readke.com/220416/010P93K6-2.jpg" type="text/javascript">< /script>

添加JavaScript文件
< script type="text/javascript"> varPerson = Backbone.Model.extend(); var person = new Person(); person.set({ fname: "Sheela", lname:"Sharma"}); document.write("What's my name: ", person.get('fname')); < /script>

第一个Backbone.js示例
< !DOCTYPE html> < head> < title>Model Example< /title> < script src="http://img.readke.com/220416/010Pa614-0.jpg" type="text/javascript">< /script> < script src="http://img.readke.com/220416/010P93914-4.jpg" type="text/javascript">< /script> < script src="http://img.readke.com/220416/010P924E-5.jpg" type="text/javascript">< /script> < script type="text/javascript"> varPerson = Backbone.Model.extend(); var person = new Person(); person.set({ fname: "Mahesh", lname:"Sharma"}); document.write("What's my name: ", person.get('fname')); < /script> < /head> < /html>

    推荐阅读