Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/27.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 如何将选定的atribute设置为触发Reactjs中onChange(event)方法的事件_Javascript_Reactjs - Fatal编程技术网

Javascript 如何将选定的atribute设置为触发Reactjs中onChange(event)方法的事件

Javascript 如何将选定的atribute设置为触发Reactjs中onChange(event)方法的事件,javascript,reactjs,Javascript,Reactjs,我想把它设置好 selected={( props.eSimStore.showAnswerFlag && String.fromCharCode(65 + index) == props.eSimStore.question.answer )} 作为触发onChange(event)方法的事件。在我的代码中,所选的方法正在工作,但未设置为event,因此未设置为props.setNewAnswer(String.fromCharCode(65+索引

我想把它设置好

selected={( props.eSimStore.showAnswerFlag && 
            String.fromCharCode(65 + index) ==  props.eSimStore.question.answer )}
作为触发onChange(event)方法的事件。在我的代码中,所选的方法正在工作,但未设置为event,因此未设置为
props.setNewAnswer(String.fromCharCode(65+索引))
。请某人给出一个解决方案

<select
   onChange={(event) => { 
               if (props.eSimStore.examMode != 'read') {
                  let index= +event.target.value;
                  props.setNewAnswer(String.fromCharCode(65 + index));
               }}} 
> {
    props.eSimStore.question.options.map((option, index) => (
       <option
         key = {index}
         selected={( props.eSimStore.showAnswerFlag && 
                     String.fromCharCode(65 + index) == props.eSimStore.question.answer)}
         value = {index}
       >{htmlToReactParser.parse(option)}</option> ))}
</select> 
{
如果(props.eSimStore.examMode!=“读取”){
让索引=+event.target.value;
props.setNewAnswer(String.fromCharCode(65+索引));
}}} 
> {
props.eSimStore.question.options.map((选项,索引)=>(
{htmlToReactParser.parse(option)}}

请有人给我一个建议。我被困在这里几天了,请有人给我提个建议。我被困在这里好几天了