Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/9.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
React Native SegmentedControl:如何使用Typescript在onChange";事件;?_Typescript_React Native - Fatal编程技术网

React Native SegmentedControl:如何使用Typescript在onChange";事件;?

React Native SegmentedControl:如何使用Typescript在onChange";事件;?,typescript,react-native,Typescript,React Native,如何使用Typescript在onChange“事件”中键入case 我尝试使用(event:NativeEvent)作为onChange={(event:NativeEvent)=>setSegmentIndex(event.NativeEvent.selectedSegmentIndex)},但没有成功 分段控制.tsx setSegmentIndex(event.nativeEvent.selectedSegmentIndex)} /> 您想要什么类型的?我相信event对象不包含原始的值

如何使用Typescript在onChange“事件”中键入case

我尝试使用
(event:NativeEvent)
作为
onChange={(event:NativeEvent)=>setSegmentIndex(event.NativeEvent.selectedSegmentIndex)}
,但没有成功

分段控制.tsx

setSegmentIndex(event.nativeEvent.selectedSegmentIndex)}
/>

您想要什么类型的?我相信event对象不包含原始的
,只提供所选段的索引。你必须自己获得价值<回调中的代码>事件似乎推断正确: