反应本地文档提取器:URI不确定,而使用的文档拾取器对本机进行了反应
如何修复它:我想获取绝对路径,但是当在React Native中使用文档Picker时,File UEI是不确定的。
import { StyleSheet, Text, View,Button } from 'react-native'
import React from 'react'
import DocumentPicker from 'react-native-document-picker'
import RNFetchBlob from 'rn-fetch-blob'
import Pdf from 'react-native-open-pdf';
const openPdfex = () => {
const openFile = () => {
const res = DocumentPicker.pick({
type: [DocumentPicker.types.allFiles],
});
console.log("absolute path =====> " ,res.uri);
}
return (
<View>
<Text>openPdf</Text>
<Button title='Open PDF' onPress={openFile}></Button>
</View>
)
}
How to fix it:I want to get absolute path but file uei is undefined when used document picker in react native.
import { StyleSheet, Text, View,Button } from 'react-native'
import React from 'react'
import DocumentPicker from 'react-native-document-picker'
import RNFetchBlob from 'rn-fetch-blob'
import Pdf from 'react-native-open-pdf';
const openPdfex = () => {
const openFile = () => {
const res = DocumentPicker.pick({
type: [DocumentPicker.types.allFiles],
});
console.log("absolute path =====> " ,res.uri);
}
return (
<View>
<Text>openPdf</Text>
<Button title='Open PDF' onPress={openFile}></Button>
</View>
)
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在文档中,它指出documentpicker.pick()返回承诺,并且由于您没有解决诺言,因此您无法从中获得URI。
尝试一下,看看它是否有效。
In the documentation, it states that DocumentPicker.pick() returns a promise and because you did not resolve the promise, you are not able to get back the uri from it.
Try this and see if it works.
尝试一下它有效的
Try this one it works
使用
documentpicker.picksingle
而不是documentpicker.pick
Use
DocumentPicker.pickSingle
instead ofDocumentPicker.pick