【发布时间】:2018-06-18 18:13:14
【问题描述】:
通常,我使用fetch 更容易做到这一点,但这个包不使用fetch。
我阅读了与我类似的其他问题,这是我尝试这样做的尝试:
SelectPhoto = () =>{
ImagePicker.openPicker({
}).then((imgResponse) => {
console.log(imgResponse.path); <-- Trying to access the path
});
}
我不断收到undefined,这是我的控制台日志结果:
0:{size: 745660, mime: "image/jpeg", height: 2960, width: 1440, path: "file:///storage/emulated/0/DCIM/Screenshots/Screenshot_20180617-173313.jpg"} length:1
谁能帮我解决这个问题?非常感谢!
【问题讨论】:
-
虽然我不确定:1.) 使用
imgResponse[0].path?或 2.) 首先保护路径不被读取? -
好的,这行得通。另外,我不这么认为,因为它告诉我可以从这个包中做到这一点:npmjs.com/package/react-native-customized-image-picker。现在我需要做的就是弄清楚如何将状态更改为该路径。 @SebastianRothbucher
标签: reactjs react-native console.log