未捕获的 ReferenceError:未定义 ACDesigner

Posted

技术标签:

【中文标题】未捕获的 ReferenceError:未定义 ACDesigner【英文标题】:Uncaught ReferenceError: ACDesigner is not defined 【发布时间】:2021-09-27 19:39:01 【问题描述】:

我正在尝试使用 Adaptive Card Designer 构建一个 html 页面。

我正在按照说明使用本文档中的 CDN 方法:

https://www.npmjs.com/package/adaptivecards-designer

感谢任何输入。非常感谢! :)

它抛出以下错误:

Uncaught ReferenceError: ACDesigner is not defined

我的 HTML 文件如下:

<html>

<head>
</head>
<script src="https://unpkg.com/adaptivecards@latest/dist/adaptivecards.min.js"></script>
<script src="https://unpkg.com/adaptive-expressions@4/lib/browser.js"></script>
<script src="https://unpkg.com/adaptivecards-templating@latest/dist/adaptivecards-templating.min.js"></script>
<script src="https://unpkg.com/markdown-it@8.4.0/dist/markdown-it.min.js"></script>
<script src="https://unpkg.com/monaco-editor@0.17.1/min/vs/loader.js"></script>
<!-- <script src="https://unpkg.com/adaptivecards-designer@latest/dist/adaptivecards-designer.min.js"></script> -->
<script src="https://unpkg.com/adaptivecards-designer@latest/dist/adaptivecards-designer-standalone.min.js"></script>
<script type="text/javascript">
    window.onload = function () 
        let hostContainers = [];
        let designer = new ACDesigner.CardDesigner(hostContainers);
        designer.assetPath = "https://unpkg.com/adaptivecards-designer@latest/dist";
        require.config( paths:  'vs': 'https://unpkg.com/monaco-editor@0.17.1/min/vs'  );
        require(['vs/editor/editor.main'], function () 
            designer.monacoModuleLoaded();
        );
        designer.attachTo(document.getElementById("designerRootHost"));
    ;
</script>

<body>
    <div id="designerRootHost"></div>
</body>

</html>

【问题讨论】:

【参考方案1】:

monaco-editor 对加载模块的过程有影响,请更改顺序,先加载adaptivecards-designer

<!-- <script src="https://unpkg.com/adaptivecards-designer@latest/dist/adaptivecards-designer.min.js"></script> -->
<script src="https://unpkg.com/adaptivecards-designer@latest/dist/adaptivecards-designer-standalone.min.js"></script>
<script src="https://unpkg.com/monaco-editor@0.17.1/min/vs/loader.js"></script>

【讨论】:

以上是关于未捕获的 ReferenceError:未定义 ACDesigner的主要内容,如果未能解决你的问题,请参考以下文章

未捕获的 ReferenceError:未定义 showCategory

未捕获的 ReferenceError:“$ 未定义”[重复]

PhoneGap 错误 - “未捕获的 ReferenceError:cordova 未定义”

未捕获的 ReferenceError:$ 未定义 [重复]

未捕获的 ReferenceError:未定义窗口

未捕获的 ReferenceError:未定义 url