PptxGenjs writeFile() 在 IE11 中不工作

PptxGenjs writeFile() not working in IE11

虽然一切似乎都工作正常,但当调试器点击 pres.writeFile() 函数时,我根本无法获取 pptx。主要是基于承诺的问题。当然,当使用 Chrome 进行测试时,一切都按原样运行。有人以前遇到过类似的问题吗?有什么建议么? IE11 有什么问题?

    var pres = new pptxgen();

function fetch_data(el) {
    $.ajax({
        url:`${document.querySelector('.off-to-see-the-wizard > .route').innerHTML}`,
        contentType:"application/json",
        dataType:"json",
        success:function(response){
            if(response)
            {                 
                var data=JSON.parse(response);
                createPresentation(data,el);
            }
            else{
                console.log(response)
            }
        },
        error:function(err){
            console.log(err);
        }
    })
}


function createPresentation(data){
    var second_image="image/base64 ...."
    var main_image="image/jpg;base64 ..."

    function createMasterSlide(pres){
        pres.defineSlideMaster({
                title:'MASTER_SLIDE',
                bkgd:  'FFFFFF',
                objects:[
                    {'text':{text:`Test ${data._gateDescript} review`,options:{color:'000000',x:4.7,y:6.77,h:0.46,w:3.63, fontSize:14}}},
                    {'image':{x:0.3,y:6.47,w:1.14,h:0.83,data:second_image}}
                ],
                slideNumber: { x:9.11, y:6.77 ,w:0.43 ,h:0.42}
            })
        }
    function createMainSlide(pres){
        pres.author="Team";
        pres.layout='LAYOUT_4x3';
        let main_slide=pres.addSlide();
        main_slide.addImage({data:main_image, w:10, h:7.5})
        main_slide.addText(`Project ID:  ${data._p.Id}\nProject Name: ${data._p.Name}`, {color:'D55C00' ,x:0.47, y:3.56, w:5.0, h:0.7, fontSize:24})
        main_slide.addText(`Review: Test ${data._gateDescript} \nDate: ${Date.now()} `)
        }

    createMasterSlide(pres);
    createMainSlide(pres);
    pres.writeFile('Presentation.pptx');
}

快速更新 错误 : 请参阅所附图片。 Error

Ι 了解 jszip 对 ie11 有问题 具体来说,pptxgenjs 使用运行 generateInternalStream 的 jszip。在这个函数的范围内发生了一些事情。有什么线索吗?

您使用的是哪个版本的 jszip? pptxgenjs@3.1.1 似乎默认使用 jszip v3.2.1。

我发现有些在 IE 和 Edge 中使用 jszip 版本 3.2.x 时有同样的错误。你可以参考this thread。最后一个没有这个问题的版本是 3.1.5。您可以尝试使用 jszip 版本 3.1.x.

快速更新供您参考。 通过安装 jszip 3.1.5 版本终于解决了这个问题。 使用 IE11 稳定且功能齐全。

所以你应该安装这个特定版本

npm install jszip@3.1.5 --save

然后请导航到节点模块,复制所有 jszip 节点模块。 导航回 pptxgenjs 节点模块。导航到 pptxgenjs--->node_modules 并用您之前安装和复制的版本覆盖 jszip。

因此 pptxgenjs 库将使用 jszip 3.1.5 版本。

问题已解决。 谢谢大家:)