Home > front end >  Rewrite, please get and set function, can also how to call the original set and get functions?
Rewrite, please get and set function, can also how to call the original set and get functions?

Time:09-27


For example, the following rewrote the get and set function of x1, excuse me, here the problem of red, how to implement? :



Object. DefineProperty (_value_test prototype, "x1", {
Get: the function () : number {
Return this. Xx + 1;
},
Set: function (value: number) {
If (value=0) https://bbs.csdn.net/topics/={
This. Xx=value + 1;
} else {

call here the original set function assignment, how to achieve here??????????? (don't copy the code method)

}

}
});

CodePudding user response:

Daniel know? How to get the set function? And the function of the call set?
Here to rewrite the x1 set function,

CodePudding user response:

Found,

"_x1_set" _value_test. Prototype []=_value_test. Prototype [] "__lookupSetter__" (" x1 ");
"_x1_get" _value_test. Prototype []=_value_test. Prototype [] "__lookupGetter__" (" x1 ");