pdfMake:"Uncaught File [font.tff]" 似乎阻止功能工作

pdfMake: "Uncaught File [font.tff]" appears to prevent function from working

我以前从未使用过 pdfMake,我正在尝试通过单击按钮将一些文本转换为 PDF。我正在将 pdfMake 导入 index.js,所以我不确定 pdfMake 本身是否正常工作。

我收到一个控制台错误:Uncaught File 'Roboto-Regular.ttf' not found in virtual file system,我认为它阻止了该功能 运行。我稍微调整了 index.js 文件(参见注释代码),但仍然没有。对此有什么想法吗?

index.js:

import 'jquery';
import './SiteAssets/styles/RecruitmentTracking.css';
import 'bootstrap/dist/css/bootstrap.min.css';

import './SiteAssets/scripts/printPDF.js';

import 'jquery-ui-bundle/jquery-ui.min.js';
import 'bootstrap/dist/js/bootstrap.bundle.min.js';

import 'pdfmake/build/pdfmake.min.js';
import 'pdfmake/build/vfs_fonts';

// import pdfFonts from "pdfmake/build/vfs_fonts";
// pdfMake.vfs = pdfFonts.pdfMake.vfs;
// require('imports-loader?this=>window!pdfmake/build/vfs_fonts.js');

console.log('this is index.js');

printPDF.js:

import $ from 'jquery';
// import { pdfMake } from 'pdfmake/build/vfs_fonts';
import pdfMake from 'pdfmake/build/pdfmake.min.js';

console.log('this is printPDF')

function _myFunc() {

    var docDefinition = {
        content: [
            'First paragraph',
            'Another paragraph, this time a little bit longer to make sure, this line will be divided into at least two lines'
        ]
    };

    pdfMake.createPdf(docDefinition).download('test.pdf');
    console.log(docDefinition.content)

}

$("#pdf-trigger").on("click", _myFunc)

console.log(_myFunc)

index.html:

<!-- Button trigger PDF -->
        <button type="button" class="btn btn-secondary" 
          id="pdf-trigger" data-toggle="" 
          data-target="#pdfprint">PDF Print</button>

console.log:

log.js?1afd:24 - [HMR] Waiting for update signal from WDS...

printPDF.js?40b7:5 - this is printPDF

pdfmake.min.js?be6c:8 - Uncaught File 'Roboto-Regular.ttf' not found in virtual file system

client?56b6:85 - [WDS] Hot Module Replacement enabled.

更新:

根据 GH 用户 RizkiDPrast's suggestion,我进入 vfs_fonts.js 并将顶行从:this.pdfMake = this.pdfMake || {}; this.pdfMake.vfs = { 编辑为:pdfMake = pdfMake || {}; pdfMake.vfs = {