所以,我遇到了这个问题:我这里有这种类型的元素,显然在更改输入时有事件,是否可以像这样传递参数并访问事件?如果是这样,我该怎么办?
// 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)} />
Run Code Online (Sandbox Code Playgroud)