主要用来创建同一类对象
1##
var Name = function(content) {
this.content = content;
}
Name.prototype = {
default: function() {
return "请输入名称";
},
success: function() {
return "格式正确";
},
error: function() {
return "输入错误";
}
}
var Password = function(content) {
this.content = content;
}
Password.prototype = {
default: function() {
return "请输入密码";
},
success: function() {
return "密码格式正确";
},
error: function() {
return "输入错误";
}
}
var Login = function(name) {
seitch(name) {
case: 'name':
return new Name();
case: 'password':
return new Password();
}
}
2##
function Login(type, content) {
var o = new Object();
o.content = content;
o.default = function() {
return content[0];
}
o.success = function() {
return content[1];
}
o.error = function() {
return content[2];
}
if (type == 'name') {
}
if (type == 'password') {
}
return o;
}
var userName = Login('name', ["请输入至少4位字母、汉字","格式正确","输入格式错误,请重新输入"]);
网友评论