2016-09-01 41 views
0

我試圖訪問打印機中的「naturalWidth」,但是如果出現編譯錯誤或者我在「naturalWidth」下面出現紅線。因爲$(「#contentImg」)。height())在JavaScript和TypeScript中爲我返回0我不能操作圖像。圖像大小不一。如果我用javascript做它很好。我努力了;naturalWidth - 屬性'naturalWidth'在類型'HTMLElement'上不存在

document.getElementById('contentImg').naturalWidth; 
    $("#contentImg")[0].naturalWidth. 

這適用於JavaScript,但不適用於TypeScript。有沒有辦法獲得自然的寬度/高度?

回答

相關問題