Javascript 创建Chrome扩展时如何使用外部库
我正在尝试创建一个将DOM HTML内容转换为pdf的扩展。下面是它的样子 mainfest.jsonJavascript 创建Chrome扩展时如何使用外部库,javascript,jquery,google-chrome-extension,jspdf,html2pdf,Javascript,Jquery,Google Chrome Extension,Jspdf,Html2pdf,我正在尝试创建一个将DOM HTML内容转换为pdf的扩展。下面是它的样子 mainfest.json { "manifest_version": 2, "name": "Applicant Scraper", "description": "Scrapes all the details of the applicants that user visited.", "version&
{
"manifest_version": 2,
"name": "Applicant Scraper",
"description": "Scrapes all the details of the applicants that user visited.",
"version": "1.0",
"page_action": {
"default_icon": "icon.PNG",
"default_popup": "popup.html",
"default_title": "ApplicantScraper"
},
"content_scripts":[
{
"matches": ["https://sample.com/application/viewApplication/*"],
"js": ["content.js", "jquery-3.6.0.min.js", "jspdf.umd.min.js", "html2pdf.bundle.min.js"]
}
],
"permissions": [
"tabs",
"https://sample.com/application/viewApplication/*"
]
}
content.js
const element = document.getElementById('resumeCont');
html2pdf()
.from(element)
.save();
错误
我已经在同一个文件夹中包含了jquery和html2pdf的解包最小文件,但我在浏览器中收到了上述错误。我甚至尝试过使用jspdf来达到同样的目的,但我不知道如何调试它。也许使用合并所有文件的webpack会更容易。您可以在此处找到骨架项目: