使用Uniapp X,Hbuilder X版本4.45,调用文件保存uni.saveFile代码,运行报错, 请大家帮我看下为什么:
完整代码:
uni.downloadFile({
url: fileUrl,
success: (res : DownloadFileSuccess) => {
if (res.statusCode == 200) {
// 3. 保存到本地, 这里报错:error: Unresolved reference: uni_saveFile
uni.saveFile({
tempFilePath: res.tempFilePath,
success: function (res) {
// var savedFilePath = res.savedFilePath as string;
console.log(`文件已保存至: `);
}
})
}
},
})
11:17:47.272 [plugin:uni:app-uts] 编译失败
11:17:47.273 error: Unresolved reference: saveFile
11:19:56.330 error: Unresolved reference: uni_saveFile
2***@qq.com (作者)
谢谢,问题已解决
2025-02-05 13:12
2***@qq.com (作者)
对了,还有个问题,这个在IOS上不支持吗,那IOS如何保存文件呢?
2025-02-05 13:14
DCloud_UNI_yuhe
回复 2***@qq.com: 目前不支持,需要等待支持,或者是通过写一个 UTS 插件,调用原生 API 来实现
2025-02-05 13:49