this.file.dataDirectory 在 ionic2 中显示为 null

this.file.dataDirectory was showing null in ionic2

this.file.dataDirectory 显示为 null,我已经在全球范围内安装了 cordova,但仍然找不到任何 solution.where 我弄错了吗?

download() {

    const fileTransfer: FileTransferObject = this.transfer.create();

    const url = 'http://www.example.com/file.pdf';
    fileTransfer.download(url, this.file.dataDirectory + 'file.pdf').then((entry) => {
      console.log('download complete: ' + entry.toURL());
    }, (error) => {
      // handle error
    });
}

使用

cordova.file.dataDirectory

而不是

this.file.dataDirectory