Clear and reset form input fields

前端 未结 12 1956
小蘑菇
小蘑菇 2020-11-28 22:36

I have a form containing various input fields and two buttons; one for submitting and one for cancelling.

12条回答
  •  借酒劲吻你
    2020-11-28 23:30

    Following code should reset the form in one click.

    import React, { Component } from 'react';
    
    class App extends Component {
        constructor(props){
        	super(props);
        	this.handleSubmit=this.handleSubmit.bind(this);
        }
        handleSubmit(e){
        this.refs.form.reset();
        }
        render(){
            return(
            



    } }

提交回复
热议问题