本文介紹了TypeError:console.log.apply 上的非法調用的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
如果你在 chrome 控制臺中運行它:
If you run this in the chrome console:
console.log.apply(null, [array])
Chrome 會返回一個錯誤:
Chrome gives you back an error:
// TypeError: Illegal Invocation
為什么?(通過 OSX 在 Chrome 15 上測試)
推薦答案
當執行上下文從控制臺更改為任何其他對象時,它可能不起作用:
It may not work in cases when execution context changed from console to any other object:
這是預期的,因為 console.info 期望它的this"引用是控制臺,而不是窗口.
This is expected because console.info expects its "this" reference to be console, not window.
console.info("stuff")
stuff
undefined
console.info.call(this, "stuff")
TypeError: Illegal invocation
console.info.call(console, "stuff")
stuff
undefined
這種行為是意料之中的.
This behavior is expected.
https://bugs.chromium.org/p/chromium/問題/詳細信息?id=48662
這篇關于TypeError:console.log.apply 上的非法調用的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!