安卓系统中,本地图片保存到系统相册,如果直接用应用中的文件路径,则会保存失败,Android 因为系统原因,应用内的文件无法同步到相册,iOS 没有此限制
解决方案:先将本地图片保存到指定目录,在用指定目录到图片路径作为保存路径,此过程已经封装在 savePicToAlbum 方法中,但将本地图片保存到指定目录这一过程需要 MFileManager 插件,所以使用此方法前先保证安装了 MFileManager 插件。
import { MUtils } from '@yl/super-jssdk';
MUtils.savePicToAlbum(optional)
| 参数 | 类型 | 必填 | 作用 |
|---|---|---|---|
| optional | Object | 是 | 必选参数 |
optional
| 参数 | 类型 | 必填 | 作用 |
|---|---|---|---|
| url | string | 是 | 图片网络地址或本地绝对地址 |
| 参数 | 类型 | 作用 |
|---|---|---|
| resolve | Function | 成功回调 |
| reject | Function | 失败回调 |
MUtils.savePicToAlbum({
url: 'images/5034c0f2c8265.jpg'
}).then(res => {
console.log('res', res);
}).catch(err => {
console.log('err', err);
})