我最近将我的 Angular 应用程序从 v13 升级到了 v16。我必须解决如此多的兼容性错误,但是这个带有角度数据表的错误没有得到解决。我收到错误消息
Error: node_modules/angular-datatables/src/angular-datatables.directive.d.ts:31:25 - error TS2503: Cannot find namespace 'DataTables'.
31 dtInstance: Promise<DataTables.Api>;
~~~~~~~~~~
Error: node_modules/angular-datatables/src/models/settings.d.ts:3:38 - error TS2503: Cannot find namespace 'DataTables'.
3 export interface ADTSettings extends DataTables.Settings {
~~~~~~~~~~
Error: node_modules/angular-datatables/src/models/settings.d.ts:6:37 - error TS2503: Cannot find namespace 'DataTables'.
6 export interface ADTColumns extends DataTables.ColumnSettings {
~~~~~~~~~~
Error: Can't resolve 'node_modules/datatables.net-bs/css/dataTables.bootstrap.min.css' in 'C:\abc\AngularApplications\Applications'
8 export declare class DataTablesModule {
~~~~~~~~~~~~~~~~
当我将 Angular-Datatable 降级到 6.0.0 时,会出现此错误消息
This likely means that the library (angular-datatables) which declares DataTablesModule is not compatible with Angular Ivy. Check if a newer version of the library is available, and update if so. Also consider checking with the library's authors
to see if the library is expected to be compatible with Ivy.
这是我的 package.json 文件:
"dependencies": {
"@angular/animations": "^16.2.12",
"@angular/common": "^16.2.12",
"@angular/compiler": "^16.2.12",
"@angular/core": "^16.2.12",
"@angular/forms": "^16.2.12",
"@angular/platform-browser": "^16.2.12",
"@angular/platform-browser-dynamic": "^16.2.12",
"@angular/router": "^16.2.12",
"@ng-bootstrap/ng-bootstrap": "^15.0.0",
"@ng-select/ng-option-highlight": "^12.0.6",
"@ng-select/ng-select": "^12.0.7",
"@types/xlsx": "^0.0.36",
"angular-datatables": "^13.0.0",
"bootstrap": "^5.3.3",
"datatables.net": "^1.12.1",
"datatables.net-bs5": "^1.11.3",
"datatables.net-dt": "^1.11.3",
"file-saver": "^2.0.5",
"jquery": "^3.7.1",
"popper.js": "^1.16.1",
"tslib": "^2.3.0",
"xlsx": "^0.18.5",
"zone.js": "~0.13.0"
},
"devDependencies": {
"@angular-devkit/build-angular": "^16.2.12",
"@angular/cli": "^16.2.12",
"@angular/compiler-cli": "^16.2.12",
"@types/bootstrap": "^5.2.10",
"@types/datatables.net": "^1.12.0",
"@types/file-saver": "^2.0.7",
"@types/jasmine": "~4.3.0",
"@types/jquery": "^3.5.30",
"@types/node": "^20.12.12",
"@types/rx": "^4.1.4",
"jasmine-core": "~4.6.0",
"karma": "~6.4.0",
"karma-chrome-launcher": "~3.2.0",
"karma-coverage": "~2.2.0",
"karma-jasmine": "~5.1.0",
"karma-jasmine-html-reporter": "~2.0.0",
"rxjs": "^6.5.3",
"typescript": "^4.9.3",
"webpack-dev-server": "^5.0.4"
}
Angular 16 支持角度数据表吗?如果是,哪个版本? 如果 Angular 16 不支持 Angular-Datatables。那么替代库可以是什么呢
有什么解决办法吗? 甚至我的 Angular 版本也是 16