Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/24.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
Reactjs onKeyUp没有调用React Select_Reactjs_React Select - Fatal编程技术网

Reactjs onKeyUp没有调用React Select

Reactjs onKeyUp没有调用React Select,reactjs,react-select,Reactjs,React Select,我需要得到的字符时,有一个在多选择下拉列表中的文字变化 但onKeyUp没有开火。请查找以下代码以供参考 const options = [ { label: "option 1", value: 1 }, { label: "option 2", value: 2 }, { label: "option 3", value: 3 }, { label: "option 4", value: 4 } ]; const onKeyUp= e => {

我需要得到的字符时,有一个在多选择下拉列表中的文字变化

但onKeyUp没有开火。请查找以下代码以供参考

const options = [
    { label: "option 1", value: 1 },
    { label: "option 2", value: 2 },
    { label: "option 3", value: 3 },
    { label: "option 4", value: 4 }
  ];
  const onKeyUp= e => {

      alert(e.target.getAttribute("value"));

  };
  const onKeyDown = e => {

      //alert(e.target.getAttribute("value"));

  };
  const selectedOption =value=>{
    alert(value);
  }
  return (
    <div className="App">
      <Select options={options} onKeyUp={onKeyUp}  onKeyDown={onKeyDown} onChange={selectedOption} />
    </div>
  );
const选项=[
{标签:“选项1”,值:1},
{标签:“选项2”,值:2},
{标签:“选项3”,值:3},
{标签:“选项4”,值:4}
];
const onKeyUp=e=>{
警报(例如target.getAttribute(“值”);
};
const onKeyDown=e=>{
//警报(例如target.getAttribute(“值”);
};
const selectedOption=value=>{
警报(值);
}
返回(
);

如果您选中
react select
,您将注意到没有可用的
onKeyDown
道具

你应该考虑采用一些类似的东西:

类应用程序扩展组件{
onKeyUp=()=>{
//你的代码在这里。。。
log(“此处的代码”);
};
render(){
返回(
);
}
}
示例可用