【发布时间】:2019-06-02 23:21:00
【问题描述】:
我是 React-Native(Expo) 的新手。我想进行图像捕获,将其转换为 base64 并保存到状态。
我的代码是这样的:
return (
<View style={{ flex: 1 }}>
<Camera style={{ flex: 1 }} type={this.state.type}>
<View
style={{
flex: 1,
backgroundColor: 'transparent',
flexDirection: 'row',
}}>
<TouchableOpacity
style={{
flex: 0.1,
alignSelf: 'flex-end',
alignItems: 'center',
}}
onPress={() => {
Camera.takePictureAsync({
base64: true,
}).then(data => {
this.setState({base64:data.base64})
});
}}>
<Text style={{color: 'white' }}>
Capture
</Text>
</TouchableOpacity>
</View>
</Camera>
</View>
);
它说 takePictureAsync() 不是一个函数。我的错误截图是:
有人知道问题出在哪里吗?如何捕获图像并将其 base64 保存到状态?
【问题讨论】:
标签: react-native base64 expo