作者热门文章
- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我需要像这样检查文件夹中的文件是否存在:
file:///android_asset/contents/my.html
我试过使用 react-native-filesystem 插件
componentWillMount () {
async function checkIfFileExists() {
const fileExists = await FileSystem.fileExists('file:///android_asset/contents/my.html')
console.log(`file exists: ${fileExists}`)
}
}
我确信 my.html 文件在那里,但我在 fileExists 中得到错误。有人知道如何正确检查吗?
最佳答案
尝试使用 react-native-fs
。
看起来它们的功能正是您正在寻找的:https://github.com/johanneslumpe/react-native-fs#existsassetsfilepath-string-promiseboolean
关于javascript - react native : Is there any way to check if the file exists in android_asset folder or not?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43471016/
我是一名优秀的程序员,十分优秀!