$(function () { let loadHtmlArr = [ "cover", // "catalog", "preface", "section_1", "section_2", "section_3", "section_4", ]; $(".pdf_root").html(loadHtmlArr.map(htmlName => { return `
`; }).join("")); loadHtmlArr.forEach(htmlName => { if (htmlName === "preface") { $(`.${htmlName}_html_root`).data("page-params", JSON.stringify({ htmlName, subjectname: "语文", num: 12 })); } else if (htmlName === "section_1") { $(`.${htmlName}_html_root`).data("page-params", JSON.stringify({ htmlName, subjectname: "数学", num: 33 })); } $(`.${htmlName}_html_root`).load(`../sections/${htmlName}.html`); }); });