exists
判断文件是否存在
import { MFileManager } from "@yl/super-jssdk"
MFileManager.exists(optional)
参数说明
| 参数 |
类型 |
必填 |
作用 |
| optional |
Object |
是 |
必填参数 |
optional
| 参数 |
类型 |
必填 |
作用 |
| path |
string |
是 |
文件的绝对路径 |
返回说明
| 参数 |
类型 |
作用 |
| resolve(boolean) |
Function |
文件存在返回 true,文件不存在返回 false |
| reject(err) |
Function |
接口出错,err为详细错误信息,是一个json对象,例如:{"errCode":-1,"errMsg":"出错啦"} |
代码示例
MFileManager.exists({
path: 'file:///storage/emulated/0/Android/data/com.mysoft.smartengineertest/images/workbench-configs/cjap-icon/ncov.png'
}).then(res => {
if (res) {
console.log('文件存在');
} else {
console.log('文件不存在');
}
}).catch(err => {
console.error(err);
})