Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/426.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 将React prop传递到DOM元素时出现问题_Javascript_Html_Reactjs_React Templates - Fatal编程技术网

Javascript 将React prop传递到DOM元素时出现问题

Javascript 将React prop传递到DOM元素时出现问题,javascript,html,reactjs,react-templates,Javascript,Html,Reactjs,React Templates,我试图将输入限制为整数。我试图传递step属性,当直接在HTML中使用时,它似乎可以工作,但是我很难从react中传递它。下面是我的渲染方法,数字输入在底部。我遇到的问题是输入仍然接受十进制 render() { const { currentVariableValue, type, currentVariable, variablePayload, } = this.props const lowHi = this.ge

我试图将输入限制为整数。我试图传递step属性,当直接在HTML中使用时,它似乎可以工作,但是我很难从react中传递它。下面是我的渲染方法,数字输入在底部。我遇到的问题是输入仍然接受十进制

render() {
    const {
      currentVariableValue,
      type,
      currentVariable,
      variablePayload,
    } = this.props

    const lowHi = this.getLowHi()
    const lowHiDisplay = `between ${lowHi[0]} and ${lowHi[1]}`
    /* eslint-disable no-nested-ternary */
    return (
      <ResponseContainer>
        {
          type === 'text' ?
            <TransparentTextArea
              autoFocus
              type="text"
              value={ currentVariableValue }
              onChange={ this.handleUpdateValue }
              onFocus={ this.handleFocus }
              onKeyPress={ this.handleKeyPress }
              key={ currentVariable }
            /> :
            type === 'paragraph' ?
              <TransparentTextArea
                autoFocus
                type="text"
                value={ currentVariableValue }
                onChange={ this.handleUpdateValue }
                onFocus={ this.handleFocus }
                onKeyPress={ this.handleKeyPress }
                key={ currentVariable }
                style={ { height: '300px', width: '95%', fontSize: '1.4em' } }
              /> :
              <TransparentInput
                autoFocus
                type="numeric"
                value={ currentVariableValue }
                onChange={ this.handleUpdateValue }
                onFocus={ this.handleFocus }
                onKeyPress={ this.handleKeyPress }
                key={ currentVariable }
                invalid={ !variablePayload.isValid }
                step={ 1 }
              />
        }
render(){
常数{
currentVariableValue,
类型,
当前变量,
可变有效载荷,
}=这是道具
const lowHi=this.getLowHi()
const lowHiDisplay=`介于${lowHi[0]}和${lowHi[1]}之间`
/*eslint禁用无嵌套三值*/
返回(
{
类型=='text'?
:
类型=='段落'?
:
}

在透明输入中,是否将{…props}传递给输入元素?

在透明输入中,是否将{…props}传递给输入元素?

错误在
类型中。
将其更改为
number
。例如:

<TransparentInput
  autoFocus
  type="number"

错误在您的
类型中。
将其更改为
number
。例如:

<TransparentInput
  autoFocus
  type="number"

>从react传递的问题是字段is仍然接受十进制值。>从react传递的问题是字段is仍然接受十进制值。