• input输入框


    import TextField from '@material-ui/core/TextField';
    
    
    /**
     * @param error 是否是错误
     * @param fullWidth 是否全部宽度
     * @param placeholder 说明文字
     * @param remark 追加说明
     * @param multiline 是否是多行属性.
     * @param required 是否必填
     * @param type 类型
     * @param name 当前属性值.
     * @param disabled 是否可用
     * @param inputProps : {min:16, max:33 }, 限制最大最小值
     * @param onChange 更新处理方法
     */
    
    class JInput extends React.Component {
    
        constructor(props){
            super(props);
            this.state={
                value:'',
                inputProps:{
                    min:0,
                }
            }
        }
    
    
        static getDerivedStateFromProps(nextProps) {
            if (nextProps && null != nextProps && undefined != nextProps.onChange) {
                return {
                    value : nextProps.value || '',
                    inputProps : nextProps.inputProps || { min:0, },
                }
            }
            return null;
        }
    
        onChange = (evt)=>{
            const fix =evt.target.value;
            console.log(fix)
            const {onChange,name} = this.props;
            if(onChange)
                onChange(fix,name);
            else
                this.setState({value:fix});
        }
    
    
        render() {
            const { error, fullWidth = true, placeholder = 'placeholder',
                type = "text",disabled=false,required=false,
                remark, multiline = false,style } = this.props;
            const {value,inputProps} = this.state;
            return (<TextField inputProps={inputProps}
                label={placeholder}
                fullWidth={fullWidth}
                error={error}
                type={type}
                required={required}
                size="small"
                disabled={disabled}
                value={value}
                onChange={this.onChange}
                multiline={multiline}
                helperText={remark}
                variant="outlined"
                style={style}
            />);
        }
    }
    
    export default JInput;
    import TextField from '@material-ui/core/TextField';
    
    
    /**
     * @param error 是否是错误
     * @param fullWidth 是否全部宽度
     * @param placeholder 说明文字
     * @param remark 追加说明
     * @param multiline 是否是多行属性.
     * @param required 是否必填
     * @param type 类型
     * @param name 当前属性值.
     * @param disabled 是否可用
     * @param inputProps : {min:16, max:33 }, 限制最大最小值
     * @param onChange 更新处理方法
     */
    
    class JInput extends React.Component {
    
        constructor(props){
            super(props);
            this.state={
                value:'',
                inputProps:{
                    min:0,
                }
            }
        }
    
    
        static getDerivedStateFromProps(nextProps) {
            if (nextProps && null != nextProps && undefined != nextProps.onChange) {
                return {
                    value : nextProps.value || '',
                    inputProps : nextProps.inputProps || { min:0, },
                }
            }
            return null;
        }
    
        onChange = (evt)=>{
            const fix =evt.target.value;
            console.log(fix)
            const {onChange,name} = this.props;
            if(onChange)
                onChange(fix,name);
            else
                this.setState({value:fix});
        }
    
    
        render() {
            const { error, fullWidth = true, placeholder = 'placeholder',
                type = "text",disabled=false,required=false,
                remark, multiline = false,style } = this.props;
            const {value,inputProps} = this.state;
            return (<TextField inputProps={inputProps}
                label={placeholder}
                fullWidth={fullWidth}
                error={error}
                type={type}
                required={required}
                size="small"
                disabled={disabled}
                value={value}
                onChange={this.onChange}
                multiline={multiline}
                helperText={remark}
                variant="outlined"
                style={style}
            />);
        }
    }
    
    export default JInput;
    未闻花名
  • 相关阅读:
    Poj1163 The Triangle(动态规划求最大权值的路径)
    Poj1258_Agri-Net(最小生成树)
    Poj1258_Agri-Net(最小生成树)
    Poj1218_THE DRUNK JAILER(水题)
    Poj1218_THE DRUNK JAILER(水题)
    Poj1298_The Hardest Problem Ever(水题)
    Poj1298_The Hardest Problem Ever(水题)
    Poj1012_Joseph
    Poj1012_Joseph
    Poj_1008--Maya Calendar
  • 原文地址:https://www.cnblogs.com/duokexiao/p/13808568.html
Copyright © 2020-2023  润新知