获取TypeError:o不是使用Webpack的函数

时间:2018-01-18 18:27:07

标签: angular webpack

我收到错误" TypeError:o不是函数"在尝试下载文件时。我怀疑这个错误是由于webpack(使用2.6.1)而没有它,代码运行正常。

应用程序有一个包含按钮的简单模板,点击它就可以下载文件。我在package.json中包含了文件保护程序并安装了相同的文件。还从webpack配置中定义的所有加载器和测试中排除了节点模块。

尝试安装babel-plugin-add-module-export而没有运气。

感谢您的输入以解决此问题。

以下是代码。

  public download() {

    let self = this;

    // Status flag used in the template.
    this.pending = true;

    // Create the Xhr request object
    let xhr = new XMLHttpRequest();
    xhr.open('GET', "Report.pdf", true);
    xhr.responseType = 'blob';

    xhr.onreadystatechange = function () {

      setTimeout(() => { self.pending = false; }, 0);


        if (xhr.readyState === 4 && xhr.status === 200) {
            var blob = new Blob([this.response], { type: 'application/pdf' });
            saveAs(blob, 'Report.pdf');
        }
    };

    // Start the Ajax request
    xhr.send();
}

0 个答案:

没有答案
相关问题