我有像这样的javascript基本功能;
roomBase = function () {
this.go = function(){
alert(1);
}
}
我有这样的房间对象;
myRoom = function(){
this.go = function(){
alert(456);
}
}
myRoom.prototype = new roomBase();
theRoom = new myRoom();
当我致电theRoom.go()
时,我收到来自prototype
的提醒。我想要的是来自myRoom
功能的警报。
答案 0 :(得分:2)
对我来说很好。 (它警告456
)
您确定一切正常吗?
演示代码:
var roomBase = function () {
this.go = function(){
alert(1);
}
}
var myRoom = function(){
this.go = function(){
alert(456);
}
}
myRoom.prototype = new roomBase();
var theRoom = new myRoom();
theRoom.go()