首页 / JAVASCRIPT / emberJS
emberJS
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了emberJS,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1943字,纯文字阅读大概需要3分钟。
内容图文
<!doctype html> <html> <head> <meta charset="utf-8"> <title>无标题文档</title> <script src="http://localhost:81/js/jquery.min.js"></script> <script src="http://localhost:81/js/handlebars.js"></script> <script src="http://localhost:81/js/emberjs.js"></script> </head> <body> <script> function log(v){ console.warn(v) } var MyApp = {}; //demo1 MyApp.president = Ember.Object.create({ name: "Barack Obama" }); MyApp.country = Ember.Object.create({ //presidentName = Ember.Binding(MyApp.president.name) presidentNameBinding: ‘MyApp.president.name‘ }); log( MyApp.country.get(‘presidentName‘) ); //demo2 MyApp.president = Ember.Object.create({ firstName: "Barack", lastName: "Obama", fullName: function() { return this.get(‘firstName‘) + ‘ ‘ + this.get(‘lastName‘); // Tell Ember that this computed property depends on firstName // and lastName }.property(‘firstName‘, ‘lastName‘) }); log( MyApp.president.get(‘fullName‘) ); //demo3 //新建模型,模型拥有say方法; var Person = Ember.Object.extend({ say: function(thing) { alert(thing); } }); //实例化Person //var person = Person.create(); //person.say("hello world"); var tom = Person.create({ name : "tom", helloWorld : function(){ this.say("Hi " + this.get("name")) } }); //tom.helloWorld(); var yehuda = Person.create({ name : "qihao", say : function(){ var name = this.get("name"); console.log( name ) //console.log( this._super() ) //this._super("hello"+name) } }); //yehuda.say() var loud = Person.extend({ say : function(thing){ //this._super有问题,不知道怎么回事; //this._super(thing); } }) loud("nono"); /* Person.reopen({ say : function(){ alert(1) } }) */ //(new Person).say() </script> <script type="text/x-handlebars"> The President of the United States is {{MyApp.president.fullName}} </script> </body> </html>
原文:http://www.cnblogs.com/diligenceday/p/3659038.html
内容总结
以上是互联网集市为您收集整理的emberJS全部内容,希望文章能够帮你解决emberJS所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。