无法读取未定义的 属性 'createPromiseCapability'
Cannot read property 'createPromiseCapability' of undefined
我正在尝试在使用 amd.min.js
作为依赖项的 Angular 项目中使用 ngx-extended-pdf-viewer
。如果我删除 amd 作为依赖项,它工作正常。但遗憾的是我无法删除它,因为很多其他东西都依赖于它。
这是可重现的 html。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Hi Duniya</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/4.0.0/system.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/4.0.0/extras/amd.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/4.0.0/extras/named-exports.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/4.0.0/extras/named-register.min.js"></script>
<script src="https://unpkg.com/ngx-extended-pdf-viewer@9.0.0-alpha.5/assets/pdf.worker-2.7.684.js"></script>
<script src="https://unpkg.com/ngx-extended-pdf-viewer@9.0.0-alpha.5/assets/pdf-2.7.684.js"></script>
<script src="https://unpkg.com/ngx-extended-pdf-viewer@9.0.0-alpha.5/assets/viewer-2.7.684.js"></script>
</head>
<body>
hello
</body>
</html>
在 amd 之前加载所有三个 pdf 模块。
<script src="https://unpkg.com/ngx-extended-pdf-viewer@9.0.0-alpha.5/assets/pdf.worker-2.7.684.js"></script>
<script src="https://unpkg.com/ngx-extended-pdf-viewer@9.0.0-alpha.5/assets/pdf-2.7.684.js"></script>
<script src="https://unpkg.com/ngx-extended-pdf-viewer@9.0.0-alpha.5/assets/viewer-2.7.684.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/4.0.0/system.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/4.0.0/extras/amd.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/4.0.0/extras/named-exports.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/4.0.0/extras/named-register.min.js"></script>
说明
pdf-viewer.js
检查 window 对象中是否存在 pdf
模块。但是,当 amd
模块首先加载时 pdf.js
不要存储在 window 对象中,而是将其注册为 amd 模块。
else if(typeof define === 'function' && define.amd)
define("pdfjs-dist/build/pdf", [], factory);
如果您在 amd
之前加载 pdf.js
,将执行以下行,使 pdf
模块在 window 对象(根是 window)中可用。
root["pdfjs-dist/build/pdf"] = root.pdfjsLib = factory();
以上片段来自https://unpkg.com/ngx-extended-pdf-viewer@9.0.0-alpha.5/assets/pdf-2.7.684.js
我正在尝试在使用 amd.min.js
作为依赖项的 Angular 项目中使用 ngx-extended-pdf-viewer
。如果我删除 amd 作为依赖项,它工作正常。但遗憾的是我无法删除它,因为很多其他东西都依赖于它。
这是可重现的 html。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Hi Duniya</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/4.0.0/system.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/4.0.0/extras/amd.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/4.0.0/extras/named-exports.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/4.0.0/extras/named-register.min.js"></script>
<script src="https://unpkg.com/ngx-extended-pdf-viewer@9.0.0-alpha.5/assets/pdf.worker-2.7.684.js"></script>
<script src="https://unpkg.com/ngx-extended-pdf-viewer@9.0.0-alpha.5/assets/pdf-2.7.684.js"></script>
<script src="https://unpkg.com/ngx-extended-pdf-viewer@9.0.0-alpha.5/assets/viewer-2.7.684.js"></script>
</head>
<body>
hello
</body>
</html>
在 amd 之前加载所有三个 pdf 模块。
<script src="https://unpkg.com/ngx-extended-pdf-viewer@9.0.0-alpha.5/assets/pdf.worker-2.7.684.js"></script>
<script src="https://unpkg.com/ngx-extended-pdf-viewer@9.0.0-alpha.5/assets/pdf-2.7.684.js"></script>
<script src="https://unpkg.com/ngx-extended-pdf-viewer@9.0.0-alpha.5/assets/viewer-2.7.684.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/4.0.0/system.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/4.0.0/extras/amd.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/4.0.0/extras/named-exports.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/4.0.0/extras/named-register.min.js"></script>
说明
pdf-viewer.js
检查 window 对象中是否存在 pdf
模块。但是,当 amd
模块首先加载时 pdf.js
不要存储在 window 对象中,而是将其注册为 amd 模块。
else if(typeof define === 'function' && define.amd)
define("pdfjs-dist/build/pdf", [], factory);
如果您在 amd
之前加载 pdf.js
,将执行以下行,使 pdf
模块在 window 对象(根是 window)中可用。
root["pdfjs-dist/build/pdf"] = root.pdfjsLib = factory();
以上片段来自https://unpkg.com/ngx-extended-pdf-viewer@9.0.0-alpha.5/assets/pdf-2.7.684.js