2
var vehiclePage = (function(){
// defined these 3 public variable. to share between zoomNoShowFee & submitVehicle
this.obj;
this.rate;
this.idx;
var setPara = function(o,t,i){
this.obj = o;
this.rate = t;
this.idx = i;
}
return {
zoomNoShowFee : function(o,t,i){
// this is existing function. I need to access o,t,i inside submitVehicle function.
setPara(o,t,i); // wrote this private function to set values
},
submitVehicle : function(){
// here I need to access zommNoShowFee's parameter
alert(this.rate);
}
} // return
})();
vehiclePage.zoomNoShowFee(null,5,3);
vehiclePage.submitVehicle(); // getting undefined
zoomNoShowFee已經存在。其他一些開發人員寫了這個。我想使用submitVehicle中傳遞給zoomNoShowFee參數的值。從javascript中訪問另一個函數的參數
爲此,我在頂部聲明瞭3個公共變量,並嘗試使用setPara專用函數存儲值。這樣我就可以訪問submitVehicle函數內部的那些公共變量。
但得到未定義調用vehhiclePage.submitVehilce時()
從根本上說,我做錯了什麼。但不知道在哪裏...
感謝您的幫助......