码迷,mamicode.com
首页 > 编程语言 > 详细

javascript模块

时间:2015-12-10 19:10:36      阅读:136      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!