myT*_*532 2 react-native react-native-image-picker
我正在尝试使用 react-native-image-picker,但出现错误:NativeModule.ImagePickermanager 为空。
import React, { Component } from 'react';
import { Text, View, StyleSheet, Alert, PixelRatio, Image } from 'react-native';
import ImagePicker from 'react-native-image-picker';
...
handleChoosePhoto = () => {
const options = {
noData: true,
};
ImagePicker.launchImageLibrary(options, response => {
if (response.uri) {
this.setState({ photo: response });
}
});
};
...
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
{this.state.photo && (
<Image
source={{ uri: this.state.photo.uri }}
style={{ width: 300, height: 300 }}
/>
)}
<Button title="Choose Photo" onPress={this.handleChoosePhoto} />
</View>
Run Code Online (Sandbox Code Playgroud)
我试着跑react-native link react-native-image-picker。当我运行此命令时,没有任何反应。它不会在终端中显示任何内容。我正在使用IOS模拟器。
小智 5
从过去 8 小时开始,我一直在尝试解决此错误,但未能成功。请使用 expo 中的 ImagePicker,这是它的链接。https://docs.expo.io/versions/latest/sdk/imagepicker/ 它将解决您的错误。
| 归档时间: |
|
| 查看次数: |
3643 次 |
| 最近记录: |