如何修复windows.onload中文档对象的未定义错误?

时间:2019-04-23 03:21:40

标签: javascript reactjs google-chrome google-chrome-devtools

每当我运行任何React应用时,都会弹出以下错误消息。

Uncaught TypeError: Cannot read property 'document' of undefined
    at window.onload (content.js:5)
    window.onload   @   content.js:5
load (async)        
    (anonymous) @   content.js:1

content.js中的内容是

window.onload=function()
{

    //Create an object for the frame
    var firstFrame = window.parent.frames[0].document;

    //Set JQuery events to run in the context of the frame
    $("#transliterateDiv", firstFrame).html("check");


    chrome.storage.local.get('typeNepaliContents', function(result){
        data = result;    
     });
}

代码不会打扰React工作流程,但是错误仍然困扰着我。什么是快速解决方案?

0 个答案:

没有答案