gpt4 book ai didi

javascript - react native : Is there any way to check if the file exists in android_asset folder or not?

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:13:10 24 4
gpt4 key购买 nike

我需要像这样检查文件夹中的文件是否存在:

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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com