首页 > 编程语言 > 详细

javascript模块

时间:2015-12-10 19:07:44      阅读:151      评论:0      收藏:0      [点我收藏+]

//使用模块
template = {};
template.createObj = (function(){
//私有成员
var _age = "";
var _name = "";

//公有访问方法
return{
//设置器
setAge:function(age){
this._age = age;
},
setName:function(age){
this._name = age;
},
getAge:function(age){
return this._age;
},
getName:function(age){
return this._name;
},
print:function(){
console.log(this.getName() + ":" + this.getAge());
}
}
});
var wzg = template.createObj();
wzg.setName("吴志刚");
//wzg.setAge("24");
wzg.print();

javascript模块

原文:http://www.cnblogs.com/cangowu/p/5036866.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!