未定义不是对象(评估‘_this.camera’)
2020-10-18
504
我尝试在
<View>
组件内显示自拍相机的相机信息,但一直出现此错误。我尝试重新安装 react-native-camera 并使用 expo-camera
,但我完全没有主意。
代码:
import {RNCamera, Camera} from 'react-native-camera'
import { View,Text,Screen,Image } from 'react-native';
import Button from 'apsl-react-native-button';
import React from 'react';
export default function Reunion ({navigation}){
return (
<View style={{
backgroundColor: "#fff",
flex:1,
alignItems: 'center',
justifyContent: 'center'
}}>
<View
style={{
position: 'relative',
left:0,
top:-15,
width:1080,
height:480,
backgroundColor: '#c4c4c4'
}}
>
<RNCamera
style={{ flex: 1, alignItems: 'center' }}
captureAudio={false}
ref={ref => {
this.camera = this.camera.bind(this )
this.camera = ref
}}
/>
</View>
</View>
)
}
1个回答
这可能会有帮助
import {RNCamera, Camera} from 'react-native-camera'
import { View,Text,Screen,Image } from 'react-native';
import Button from 'apsl-react-native-button';
import React from 'react';
export default function Reunion ({navigation}){
const cameraRef = React.createRef();
return (
<View style={{
backgroundColor: "#fff",
flex:1,
alignItems: 'center',
justifyContent: 'center'
}}>
<View
style={{
position: 'relative',
left:0,
top:-15,
width:1080,
height:480,
backgroundColor: '#c4c4c4'
}}
>
<RNCamera
style={{ flex: 1, alignItems: 'center' }}
captureAudio={false}
ref={cameraRef}
/>
</View>
</View>
)
}
Nooruddin Lakhani
2020-10-19