Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/469.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript NextJS TS TypeError null不是对象,只有在部署时,开发服务器才能正常工作_Javascript_Typescript_Deployment_Next.js - Fatal编程技术网

Javascript NextJS TS TypeError null不是对象,只有在部署时,开发服务器才能正常工作

Javascript NextJS TS TypeError null不是对象,只有在部署时,开发服务器才能正常工作,javascript,typescript,deployment,next.js,Javascript,Typescript,Deployment,Next.js,我试图在站点上设置div的内部HTML,但是它告诉我它是空的。同样的代码在dev服务器上运行良好,但在部署到Vercel之后就无法运行了 var heroTitle = r.data.data.posts.edges[7].node.text.title; document.getElementById("heroTitle").innerHTML = heroTitle; 收到的错误是 TypeError: null is not an object (e

我试图在站点上设置div的内部HTML,但是它告诉我它是空的。同样的代码在dev服务器上运行良好,但在部署到Vercel之后就无法运行了

    var heroTitle = r.data.data.posts.edges[7].node.text.title;
    document.getElementById("heroTitle").innerHTML = heroTitle;
收到的错误是

TypeError: null is not an object (evaluating 'document.getElementById("heroTitle").innerHTML = heroTitle')
换句话说,它似乎无法在站点上找到id“heroTitle”,即使“hero”div中的h1的id为
heroTitle