【发布时间】:2016-07-16 22:15:44
【问题描述】:
我正在将 webpack 与 React 一起使用,但我一生都无法理解这个构建中发生了什么。这是应该发生的事情。
var headerInput 更改为输入 onChange 的任何值。
提交表单时 (onSubmit),console.log 会记录 headerInput 值。
问题:控制台记录的值是数字,通常类似于:.0.0.1。我认为这是 console.log'ing 点击事件。为什么不像 handlerInput 函数中那样赋值?
非常感谢任何帮助。 谢谢大家。
var headerInput = null;
import React from "react";
export default class Navigation extends React.Component{
handlerInput(e,headerInput){
headerInput = e.target.value;
console.log(headerInput);
};
clickSubmit(e,headerInput){
e.preventDefault();
console.log(headerInput);
};
render(){
return(
<form onSubmit={this.clickSubmit.bind(this)}>
<input type="text" placeholder="change header" onChange={this.handlerInput.bind(this)} />
<button>Change Header</button>
</form>
);
}
};
【问题讨论】: