由于小弟知識有限,在使用JavaScript 封裝類的時(shí)候遇到了下面奇怪的問題。
var AXML = Class.create();
AXML.prototype = {
initialize : function(path){
this.xmlDom = new ActiveXObject("Msxml2.DOMDocument");
this.xmlDom.load(path);
//this.xmlDom = xmlObject;
alert(this.xmlDom); // 可以輸出正確的變量 Object
this.path = path;
},
getHomePage : function(){
alert(this.xmlDom); //變量變成了沒定義
alert(this.path); // 可以輸出正確的變量
}
};
是否在類中不能使用 Object 類型傳遞呢?
因?yàn)榻?jīng)過測試,
this.path 是一個(gè)普通變量是可以正常使用的。
MK-TIANYI