角度 12 - 'healcode-widget'不是已知元素



我正在从Angular 1迁移到Angular 12。我需要从mindbody集成一个第三方模块,我在Angular 1中所要做的就是在index.html文件中包含JS文件,如下所示:

<script src="https://widgets.mindbodyonline.com/javascripts/healcode.js" type="text/javascript"></script>

之后,我可以直接使用它——见下面:

<healcode-widget data-type="schedules" data-widget-partner="object" data-widget-id="0412695814c0" data-widget-version="1"></healcode-widget>

非常简单的东西。

我在Angular 12中做了同样的事情,我得到了下面的错误消息:

Build at: 2021-08-04T10:40:55.936Z - Hash: d638a8e9e63fb049170b - Time: 420ms
Error: src/app/class/weekly/weekly.component.html:14:17 - error NG8001: 'healcode-widget' is not a known element:
1. If 'healcode-widget' is an Angular component, then verify that it is part of this module.
2. If 'healcode-widget' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.

我必须做什么才能使用第三方JS文件?这似乎是个太简单的问题,但我似乎找不到解决办法。

Thanks in advance

修复。

app.module.ts:

import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
//Same file
schemas: [ CUSTOM_ELEMENTS_SCHEMA ]

That did the trick

最新更新