Learn react, use the Webpack build tool
When HTML introduced the generated bundle.js, it was written like this:
1 <!DOCTYPE HTML>2 <HTMLLang= "en">3 <Head>4 <MetaCharSet= "UTF-8">5 <title>Document</title>6 <Scriptsrc= "Bundle.js"></Script>7 </Head>8 <Body>9 <DivID= "App"></Div>Ten </Body> One </HTML>
Result Error:
Why is it?
Isn't that OK?!!!!!!!!
1 <!DOCTYPE HTML>2 <HTMLLang= "en">3 <Head>4 <MetaCharSet= "UTF-8">5 <title>Document</title>6 </Head>7 <Body>8 <DivID= "App"></Div>9 <Scriptsrc= "Bundle.js"></Script>Ten </Body> One </HTML>
Answer: Can't read English, code still can understand ~ ~
Https://stackoverflow.com/questions/18239430/cannot-set-property-innerhtml-of-null
JS is introduced before the DOM loading is complete, causing some objects to be null, so an error is made. You can add window.onload = {}, or put JS before the body end tag and load it at last.
2017/11/07_ so obvious pit you're still jumping cannot set property ' InnerHTML ' of NULL