简体   繁体   English

NG0303:无法绑定到“ngbTooltip”,因为它不是“button”的已知属性

[英]NG0303: Can't bind to 'ngbTooltip' since it isn't a known property of 'button'

ERROR: 'NG0303: Can't bind to 'ngbTooltip' since it isn't a known property of 'button'.'

When I run tests locally for my Angular 12 project, I get this error, in all .spec files where ngbTooltip is used I use CUSTOM_ELEMENT_SCHEMA , it is impossible to track the line on which the error occurs.当我运行测试,在本地为我角12个项目,我得到这个错误,在所有的.spec文件ngbTooltip用我用CUSTOM_ELEMENT_SCHEMA ,这是不可能的跟踪发生错误的行。 It is noteworthy that the error is absent with ng serve , but appears with ng test .值得注意的是,该错误在ng serve不存在,但在ng test出现。 Tell me how to solve this problem, I tried using CUSTOM_ELEMENT_SCHEMA in the application module, it did not help.告诉我如何解决这个问题,我尝试在应用程序模块中使用CUSTOM_ELEMENT_SCHEMA ,但没有帮助。

Console output Console output 2控制台输出控制台输出 2

Try adding NgbModule to imports array in TestBed.configureTestingModule({ .尝试添加NgbModuleimports在阵列TestBed.configureTestingModule({

TestBed.configureTestingModule({
  imports: [NgbModule],
...

If you don't want to import NgbModule or it causes issues in your unit tests, you can mock the directive and provide the mock.如果你不想导入NgbModule或者它在你的单元测试中导致问题,你可以模拟指令并提供模拟。

@Directive({
  selector: '[ngbTooltip]'
})
class MockNgbTooltip {}
...
TestBed.configureTestingModule({
  // add the mock to the declarations array
  declarations: [MockNgbTooltip],

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 NG0303:无法绑定到“ngif”,因为它不是“div”的已知属性 - NG0303: Can't bind to 'ngif' since it isn't a known property of 'div' 无法绑定到“已禁用”,因为它不是&#39; <button>&#39;</button>的已知属性 - Can't bind to 'disabled' since it isn't a known property of '<button>' NG2-Charts模板解析错误:无法绑定到“数据集”,因为它不是“ canvas”的已知属性 - NG2-Charts Template parse errors: Can't bind to 'datasets' since it isn't a known property of 'canvas' NG2-Charts 无法绑定到“数据集”,因为它不是“画布”的已知属性 - NG2-Charts Can't bind to 'datasets' since it isn't a known property of 'canvas' 无法绑定到&#39;ngSwitchDefault&#39;,因为它不是&#39;ng-template&#39;的已知属性 - Can't bind to 'ngSwitchDefault' since it isn't a known property of 'ng-template' 具有Angular 4的ng2-chart:无法绑定到“数据”,因为它不是“ canvas”的已知属性 - ng2-chart with Angular 4: Can't bind to 'data' since it isn't a known property of 'canvas' 无法绑定到“数据集”,因为它不是“画布”的已知属性 - Can't bind to 'datasets' since it isn't a known property of 'canvas' 无法绑定,因为它不是选择器组件的已知属性 - Can't bind to since it isn't a known property of selector component 无法绑定到“”,因为它不是“ angular 2”的已知属性 - can't bind to '' since it isn't a known property of '' angular 2 无法绑定到“控件”,因为它不是(myComponent)的已知属性 - Can't bind to 'control' since it isn't a known property of (myComponent)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM