import React, { Component } from 'react'; import {getImageUrl} from 'educoder'; import {Modal,Input} from 'antd'; class Addshixuns extends Component { constructor(props) { super(props); this.state = { shixunname:undefined, shixunzero:false } } handleChange=(e)=>{ this.setState({ shixunname:e.target.value, }) if(e.target.value.length>0){ this.setState({ shixunzero:false }) } } modalCancel=()=>{ this.setState({ shixunname:undefined, }) this.props.modalCancel() } //判断是否为空 getshixunname( str ){ if ( str == "" ) return true; var regu = "^[ ]+$"; var re = new RegExp(regu); return re.test(str); } modalSave=()=>{ let {shixunname}=this.state; if(this.getshixunname(shixunname)===true){ this.setState({ shixunzero:true }) return } if(shixunname===undefined||shixunname.length===0){ this.setState({ shixunzero:true }) return } this.props.Setaddshixuns(shixunname); this.props.modalCancel(); } render() { return( {this.props.Addshixunstype===true?:""}

实训名称:

{this.state.shixunzero===true?

请输入实训名称

:""}
取消 确定
) } } export default Addshixuns;