本文介绍了Ng-bootstrap和Angular 9兼容性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

升级到Angular 9之后,相对于ng-bootstrap,我得到以下错误:

After upgrading to Angular 9, I am getting the following errors relative to ng-bootstrap:

ERROR.ts:87:63-错误TS2304:找不到名称"NgbDropdownMenu".

ERROR in src/app/shared/Components/form-controls/dropdown-select/dropdown-select.component.ts:87:63 -error TS2304: Cannot find name 'NgbDropdownMenu'.

87 @ViewChild('dropdownMenu',{静态:假})dropDownMenu:NgbDropdownMenu;~~~~~~~~~~~~~~~src/app/private/private-shared/Services/ngb-modal-stack-extend.service.ts:1:39-错误TS2305:模块'''../../../../../../../../../../../node_modules/@ng-bootstrap/ng-bootstrap'没有导出的成员"isString". 1 import {NgbModalRef,NgbActiveModal,isString,isDefined,NgbModalBackdrop,ContentRef,NgbModal,NgbModalWindow},来自"@ ng-bootstrap/ng-bootstrap";~~~~~~~~~src/app/private/private-shared/Services/ngb-modal-stack-extend.service.ts:1:49-错误TS2305:模块" ../../../../../../../../../../../node_modules/@ng-bootstrap/ng-bootstrap/ng-bootstrap" ;'没有导出的成员"isDefined".1 import {NgbModalRef,NgbActiveModal,isString,isDefined,NgbModalBackdrop,ContentRef,NgbModal,NgbModalWindow},来自"@ ng-bootstrap/ng-bootstrap";~~~~~~~~~~src/app/private/private-shared/Services/ngb-modal-stack-extend.service.ts:1:60-错误TS2305:模块'''../../../../../../../../../../../node_modules/@ng-bootstrap/ng-bootstrap/ng-bootstrap"没有导出的成员'NgbModalBackdrop'.

87 @ViewChild('dropdownMenu', { static: false }) dropDownMenu: NgbDropdownMenu;~~~~~~~~~~~~~~~src/app/private/private-shared/Services/ngb-modal-stack-extend.service.ts:1:39 - error TS2305: Module '"../../../../../../../../../../../node_modules/@ng-bootstrap/ng-bootstrap"' has no exported member 'isString'. 1 import { NgbModalRef, NgbActiveModal, isString, isDefined, NgbModalBackdrop, ContentRef, NgbModal,NgbModalWindow } from '@ng-bootstrap/ng-bootstrap';~~~~~~~~src/app/private/private-shared/Services/ngb-modal-stack-extend.service.ts:1:49 - error TS2305: Module'"../../../../../../../../../../../node_modules/@ng-bootstrap/ng-bootstrap/ng-bootstrap"' has noexported member 'isDefined'.1 import { NgbModalRef, NgbActiveModal, isString, isDefined, NgbModalBackdrop, ContentRef, NgbModal,NgbModalWindow } from '@ng-bootstrap/ng-bootstrap';~~~~~~~~~src/app/private/private-shared/Services/ngb-modal-stack-extend.service.ts:1:60 - error TS2305: Module '"../../../../../../../../../../../node_modules/@ng-bootstrap/ng-bootstrap/ng-bootstrap"' has noexported member 'NgbModalBackdrop'.

1 import {NgbModalRef,NgbActiveModal,isString,isDefined,NgbModalBackdrop,ContentRef,NgbModal,NgbModalWindow},来自"@ ng-bootstrap/ng-bootstrap";~~~~~~~~~~~~~~~~src/app/private/private-shared/Services/ngb-modal-stack-extend.service.ts:1:78-错误TS2305:模块" ../../../../../../../../../../../node_modules/@ng-bootstrap/ng-bootstrap/ng-bootstrap" ;'没有导出的成员"ContentRef".1 import {NgbModalRef,NgbActiveModal,isString,isDefined,NgbModalBackdrop,ContentRef,NgbModal,NgbModalWindow},来自"@ ng-bootstrap/ng-bootstrap";~~~~~~~~~~~src/app/private/private-shared/Services/ngb-modal-stack-extend.service.ts:1:100-错误TS2305:模块'''../../../../../../../../../../../node_modules/@ng-bootstrap/ng-bootstrap/ng-引导程序"已没有导出的成员'NgbModalWindow'.

1 import { NgbModalRef, NgbActiveModal, isString, isDefined, NgbModalBackdrop, ContentRef, NgbModal,NgbModalWindow } from '@ng-bootstrap/ng-bootstrap';~~~~~~~~~~~~~~~~src/app/private/private-shared/Services/ngb-modal-stack-extend.service.ts:1:78 - error TS2305: Module'"../../../../../../../../../../../node_modules/@ng-bootstrap/ng-bootstrap/ng-bootstrap"' has noexported member 'ContentRef'.1 import { NgbModalRef, NgbActiveModal, isString, isDefined, NgbModalBackdrop, ContentRef, NgbModal,NgbModalWindow } from '@ng-bootstrap/ng-bootstrap';~~~~~~~~~~src/app/private/private-shared/Services/ngb-modal-stack-extend.service.ts:1:100 - error TS2305:Module '"../../../../../../../../../../../node_modules/@ng-bootstrap/ng-bootstrap/ng-bootstrap"' hasno exported member 'NgbModalWindow'.

1 import {NgbModalRef,NgbActiveModal,isString,isDefined,NgbModalBackdrop,ContentRef,NgbModal,NgbModalWindow},来自"@ ng-bootstrap/ng-bootstrap";

1 import { NgbModalRef, NgbActiveModal, isString, isDefined, NgbModalBackdrop, ContentRef, NgbModal,NgbModalWindow } from '@ng-bootstrap/ng-bootstrap';



Package.json

    "@angular/cdk": "9.2.4",
    "@angular/common": "9.1.11",
    "@angular/compiler": "9.1.11",
    "@angular/core": "9.1.11",
    "@angular/forms": "9.1.11",
    "@angular/localize": "9.1.11",
    "@angular/material": "9.2.4",
    "@angular/platform-browser": "9.1.11",
    "@angular/platform-browser-dynamic": "9.1.11",
    "@angular/router": "9.1.11",
    "@ng-bootstrap/ng-bootstrap": "4.1.2",
    "rxjs": "6.3.3",
    },
    "devDependencies": {
       "@angular-builders/jest": "^7.2.0",
      "@angular-devkit/build-angular": "~0.1000.0",
      "@angular/cli": "^9.1.9",
      "@angular/compiler-cli": "9.1.11",
      "@schematics/angular": "^9.1.5",

推荐答案

更新与下表相关的版本

  ng-bootstrap    Angular Bootstrap CSS
    1.x.x           5.0.2   4.0.0
    2.x.x           6.0.0   4.0.0
    3.x.x           6.1.0   4.0.0
    4.x.x           7.0.0   4.0.0
    5.x.x           8.0.0   4.3.1
    6.x.x           9.0.0   4.4.1

这篇关于Ng-bootstrap和Angular 9兼容性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-26 03:07