var ajaxFileUploader = function(formId){
this.formId = formId;
console.log(this.formId); //myForm
return console.log(
document.querySelector(this.formId)// null
);
}
var foo = new ajaxFileUploader('#myFrom');
我嘗試創建一個對象和一個參數傳遞到它。傳遞paramenter爲對象,並用它來querySelector但返回null
它工作正常,當我CONSOLE.LOG這個屬性
,但是當我嘗試使用querySelector,它返回null
人知道爲什麼它返回null?
提供最少的信息來調試您的問題。向我們顯示你的HTML和相關腳本 – ScanQR
'return console.log(param)'給出'Illegal return statement'錯誤 –
'return document.querySelector(this.formId)' –