简体   繁体   English

ReactJS 不呈现所有 JSX

[英]ReactJS doesn't render all JSX

I'm building a sign in page in ReactJs.我正在 ReactJs 中构建登录页面。 I'm new to the software, so I may have used HTML instead of JSX.我是该软件的新手,所以我可能使用了 HTML 而不是 JSX。 My ReactJS code in signIn.js is below:我在 signIn.js 中的 ReactJS 代码如下:

const input = (
  <div class="omrs-input-group">
     <label class="omrs-input-underlined">
        <input required style="height:55px" id="nameFirst" />
           <span class="omrs-input-label">First Name</span>
           <span class="omrs-input-helper" id="alertFirst">Please type in your first name</span>
           <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0V0z"/><circle cx="15.5" cy="9.5" r="1.5"/><circle cx="8.5" cy="9.5" r="1.5"/><path d="M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8zm-5-6c.78 2.34 2.72 4 5 4s4.22-1.66 5-4H7z"/></svg>
     </label>
   <br/>
        
</div>
)  


ReactDOM.render(
  input,
  document.getElementById('firstNameForm')
)

When I try to render this, the warning I get is Uncaught Error: Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.当我尝试渲染它时,我得到的警告是Uncaught Error: Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings. Uncaught Error: Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings. For debugging purposes, I tried to render出于调试目的,我尝试渲染

const input = (
   <h1>Hello World!</h1>
)
ReactDOM.render(
   input,
   document.getElementById('firstNameForm')
)

and it renders onto the screen.并渲染到屏幕上。 What is my error?我的错误是什么? Any help would be appreciated!任何帮助,将不胜感激! Thanks!谢谢!

The style attribute in react expects an object value not a string. react 中的 style 属性需要一个 object 值而不是字符串。

style={{height: "55px"}}

This should fix your issue.这应该可以解决您的问题。

Code: https://stackblitz.com/edit/react-gevqap代码: https://stackblitz.com/edit/react-gevqap

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM