그래서이 문제에 직면했습니다. 여기에 이런 유형의 요소가 있습니다. 분명히 입력을 변경할 때 이벤트가 있습니다. 이와 같은 매개 변수를 전달하고 이벤트에 액세스 할 수도 있습니까? 그렇다면 어떻게 할 수 있습니까?
// this function accepts two other params index, stringValue
function onChange(index ,stringValue) {
console.log(event.target.value);
console.log("index?: " + index + " and value" + stringValue)
}
//this input is in Child Component
const index = 69;
const someRandomValue='iamstring';
<input defaultValue={name} onChange={onChange(index,iamstring)} />
curried 함수 를 사용 하여 구현할 수 있습니다 .
onChange = (index, stringValue) => (event) => {
...
}
...
<input defaultValue={name} onChange={this.onChange(index,iamstring)} />
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다