在chrome中使用调试器,ImagePicker
已设置,但当我尝试在select()函数中调用它时,ImagePicker
未定义。
我在其他模块上遇到同样的问题,所以我怀疑它与我导入它的方式或范围问题有关。
我的代码:
import React, { Component } from 'react';
import {
StyleSheet,
Text,
View,
} from 'react-native';
import Button from 'react-native-button';
var ImagePicker = require('react-native-image-picker');
// I tried this also, but it doesn't set at all.
// import { ImagePicker } from 'react-native-image-picker';
export class Upload extends Component {
constructor(props) {
super();
}
render() {
return (
<View>
<Button
style={styles.button}
onPress={this.select.bind(this)}>
Upload
</Button>
</View>
);
}
select() {
var options = {...};
ImagePicker.showImagePicker(options, (response) => {
});
}
}