无法在reactjs中的输入元素内添加链接和标签

By simon at 2018-02-28 • 0人收藏 • 24人看过

我需要在reactjs的* input元素中添加一个链接和标签* 零件。以下是我所拥有的:

render() {
  return(
    <div className="login-panel-page">
      <input type="password" id="password"
             name="password" value="" placeholder="Password" maxLength="255" autoCapitalize="off">
        <label htmlFor="password">Password</label>
        <a>Show password</a>
      </input>
    </div>
  )
}
Howev呃这里是我得到的:
bundle.js:9179 Uncaught 
Error: input is a void element tag 
and must neitherhave `children` nor use `dangerouslySetInnerHTML`. 
Check the render method of Login.
任何人都可以帮助我如何实现这一目标?

2 个回复 | 最后更新于 2018-02-28
2018-02-28   #1

输入不能有孩子,你可以做这样的事情 参考:https://github.com/facebook/react/issues/6241

 render() {
    return (
    <div className="login-panel-page">
                    <input type="password" id="password" name="password" value="" placeholder="Password" maxLength="255" autoCapitalize="off"/>
                    <label htmlFor="password">Password</label>
                    <a href="#">Show password

    </div>
    )

2018-02-28   #2

输入不能有孩子,你可以做这样的事情 参考:https://github.com/facebook/react/issues/6241

 render() {
    return (
    <div className="login-panel-page">
                    <input type="password" id="password" name="password" value="" placeholder="Password" maxLength="255" autoCapitalize="off"/>
                    <label htmlFor="password">Password</label>
                    <a href="#">Show password

    </div>
    )

登录后方可回帖

Loading...