react中onClick事件,input输入框获取,重置,返回键

import React, { Component } from 'react';
import { render } from 'react-dom';
import {hashHistory} from 'react-router';
import config from '../../../../assets/common/config';
export default class HandlerSuspend extends Component { 
    componentWillMount() {
              
    }
    componentDidMount() {
        
    }
    render() {
        return (
            <div>
                <div className="below_one">
                    <div className="b_one_stop">
                        <span>请输入手机号:</span>
                        <input type="text" ref={input => this.number = input} name="mobile" id="number" class="text" maxLength="11" placeholder="请输入手机号" />
                    </div>
                    <div className="b_one_stop">
                        <span>输入服务密码:</span>
                        <input type="password" ref={input => this.password = input} name="mobile" id="password" class="text" maxLength="6" placeholder="请输入服务密码" />
                    </div>
                    <div className="b_one_button">
                        <button onClick={this.getSuspend.bind(this)}>重置</button>
                        <button onClick={this.getSure.bind(this)}>确认</button>
                    </div>
                </div>
            </div>
        );
    }


    getSuspend(){
        let number = this.number;
        let password = this.password;
        number.value = "";
        password.value = "";
    }
    getSure(){
        console.log("点击了我");   
    }
    back(){
        setTimeout(()=>{
            hashHistory.goBack();
        },500);
    }

}

猜你喜欢

转载自blog.csdn.net/qq_40753946/article/details/83825946