2***@qq.com
2***@qq.com
  • 发布:2019-01-19 13:29
  • 更新:2019-01-19 15:24
  • 阅读:1051

#插件讨论# 【 image-tools - 瞳player 】问题描述

分类:uni-app

支持图片多选吗,比如通过chooseImage方法选择多张图片,会转base64吗

2019-01-19 13:29 负责人:无 分享
已邀请:
猫猫猫猫

猫猫猫猫 - 用户已离线

提示

可以利用promise来串行和并行的执行多个任务

// 并行  
Promise.all(paths.map(path => pathToBase64(path)))  
  .then(res => {  
    console.log(res)  
    // [base64, base64...]  
  })  
  .catch(error => {  
    console.error(error)  
  })  
// 串行  
paths.reduce((promise, path) => promise.then(res => pathToBase64(path).then(base64 => (res.push(base64), res))), Promise.resolve([]))  
  .then(res => {  
    console.log(res)  
    // [base64, base64...]  
  })  
  .catch(error => {  
    console.error(error)  
  })

该问题目前已经被锁定, 无法添加新回复