zoukankan      html  css  js  c++  java
  • 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;
    未闻花名
  • 相关阅读:
    Python 模块 itertools
    Python 字符串的encode与decode
    python 模块 hashlib(提供多个不同的加密算法)
    暴力尝试安卓gesture.key
    hdu 1300 Pearls(DP)
    hdu 1232 畅通工程(并查集)
    hdu 1856 More is better(并查集)
    hdu 1198 Farm Irrigation(并查集)
    hdu 3635 Dragon Balls(并查集)
    hdu 3038 How Many Answers Are Wrong(并查集)
  • 原文地址:https://www.cnblogs.com/duokexiao/p/13808568.html
Copyright © 2011-2022 走看看