uni-app uni.chooseFile在PC端chrome浏览器上选择文件返回的tempFiles为空
uni-app uni.chooseFile在PC端chrome浏览器上选择文件返回的tempFiles为空
操作步骤:
- 点击按钮选择文件,clog打印返回值
预期结果:
- tempFiles有信息返回
实际结果:
- tempFiles为空
bug描述:
更多关于uni-app uni.chooseFile在PC端chrome浏览器上选择文件返回的tempFiles为空的实战教程也可以访问 https://www.itying.com/category-93-b0.html
2 回复
File对象不能被序列化
更多关于uni-app uni.chooseFile在PC端chrome浏览器上选择文件返回的tempFiles为空的实战教程也可以访问 https://www.itying.com/category-93-b0.html
这是一个常见的兼容性问题。uni.chooseFile在PC端Chrome浏览器返回tempFiles为空,通常是由于浏览器安全策略限制导致的。
主要原因:
- 浏览器安全策略阻止了文件访问
- 可能缺少必要的accept属性配置
- 浏览器版本兼容性问题
解决方案:
- 检查代码中是否配置了accept属性:
uni.chooseFile({
count: 1,
type: 'all',
success: (res) => {
console.log(res.tempFiles)
}
})
- 尝试使用更具体的文件类型:
uni.chooseFile({
count: 1,
type: 'image',
extension: ['jpg', 'png', 'gif'],
success: (res) => {
console.log(res.tempFiles)
}
})

