首页 > 其他 > 详细

react 预览pdf 转换

时间:2019-11-07 12:13:54      阅读:83      评论:0      收藏:0      [点我收藏+]
function getReader(response){
  return  new Promise(function(resolve,reject){
    response.blob().then( blob => {
      const reader = new FileReader();
      reader.addEventListener("loadend", function() {
              resolve(reader.result)
      });
      reader.readAsDataURL(blob);  
  })
})
}

async function getFileObjfun (response){
  return await getReader(response);
}

在effects中设置一个转换函数 yield调用上边转换

    *getFileObj({payload},{call,put}){
            const data = yield call(getFileObjfun,payload);
            // console.log(data,"xxxx")
            yield put({
                type: 'savePDf',
                payload:data
            })
        },

react 预览pdf 转换

原文:https://www.cnblogs.com/chengyunshen/p/11811179.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!