我已经使用react-native相机创建了一个相机组件,并将其导入到App.js文件中。相机组件如下:
import React from 'react';
import {Text, View} from 'react-native';
import {RNCamera} from 'react-native-camera';
export default class Camera extends React.Component {
constructor() {
super();
this.takePicture = this.takePicture.bind(this);
}
takePicture() {
this.camera.capture().then((data) => console.log(data)).catch(err => console.error(err));
}
render() {
return (
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
<RNCamera ref={cam => {this.camera = cam}} style={preview} aspect={Camera.constants.Aspect.fill}>
<Text style={styles.capture} onPress={this.takePicture}> [CAPTURE] </Text>
</RNCamera>
</View>
)
}
}
但是运行代码Attempted import error: 'requireNativeComponent' is not exported from 'react-native-web/dist/index'
时出现此错误。为什么会这样?