从Ionic2中的pdfMake中调用函数?

时间:2018-02-02 15:48:28

标签: ionic2 pdfmake

我的离子应用程序中有以下pdfMake代码块:

pdfMake.createPdf(docDefinition).getBase64(function (encodedString) {
    pdfEncoded = encodedString;
    console.log(pdfEncoded);
    this.sendValue(pdfEncoded);
}

我得到的错误是:

  

无法读取属性' sendValue'未定义的。

调用sendValue()函数需要做什么?我能够console.log pdfEncoded的值,但无法将值传递给函数。有人能让我知道我做错了什么。

谢谢你, 甲

1 个答案:

答案 0 :(得分:0)

错误的一个原因可能是因为关键字' this'可能在您的函数(块)中未定义。检查一下,看看是否是因为这个错误,如果是这样的话:

let $this = this

然后在你的函数中使用它:

$this.sendValue(pdfEncoded);