首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

js prototype有关问题!

2012-04-11 
js prototype问题!!!!functiontest(){.......}test.prototype.hhfunction(){......}问题是 test.prototyp

js prototype问题!!!!
function   test()
{  
.......
}
test.prototype.hh=function(){......}
问题是 'test.prototype.hh "中的hh是一个变量的时候该怎么写??

[解决办法]
var variable = "变量值 ";

test.prototype.hh = variable;
[解决办法]
var Class = {
create: function() {
return function() {
this.initialize.apply(this, arguments);
}
}
}

var test = Class.create();
test.prototype = {
initialize: function() {
this.aa = 11;
},

hh: function() {
}
}
[解决办法]
function ClassA(){}
ClassA.prototype.color = "red ";
ClassA.prototype.show = function(){alert(this.color);};
[解决办法]
test.prototype.hh = xxx;
[解决办法]
function ClassA(col){
this.color = col;
}
ClassA.prototype.show = function(){alert(this.color);};
[解决办法]
eval( "test.prototype. "+hh+ "=function(){......} ");

热点排行