错误:输入是一个空元素标记,并且既不能具有“ children”,也不能使用“ dangerouslySetInnerHTML”

import React,{ Component } from 'react'

class Login extends Component{
    constructor(props){
        super(props)

    }
    render(){
        return(
            <form classname="login-form">
                <h1>login</h1>
                <div>
                    <div classname="form-group">
                        <label for="name">
                            Name :
                        </label>
                        <input name="name" type="text" value="" placeholder="Your Name" />
                    </div>
                    <div classname="form-group">
                        <label for="password">
                            Password :
                        </label>
                        <input name="password" type="Password" value="" placeholder="Password" />
                    </div>
                    <input type="submit">Submit</input>
                </div>
            </form>
        )
    }
}

export default Login
ccc287718265 回答:错误:输入是一个空元素标记,并且既不能具有“ children”,也不能使用“ dangerouslySetInnerHTML”

我认为问题在这里,

//input is an empty tag and you have provided Submit as children here
<input type="submit">Submit</input>  

应该就是这个,

<input type="submit" value="Submit" />
,

ravibagul91的答案正确。 input是自动关闭元素。你不能有孩子。

或者,您可以使用按钮:

<button type="submit">Submit</button>

对此:

<input type="submit" value="Submit" />
本文链接:https://www.f2er.com/3112892.html

大家都在问