我一直在使用 Angular 8,最近更新到 Angular 9。但是当我运行该项目时,它在控制台中向我显示了以下错误:
Error: Uncaught (in promise): TypeError: Cannot assign to read only property 'tView' of object '[object Object]' TypeError: Cannot assign to read only property 'tView' of object '[object Object]' at getOrCreateTComponentView (core.js:7621) at createRootComponentView (core.js:18895) at
这是我的 package.json :
"dependencies": {
"@angular/animations": "^9.0.4",
"@angular/cdk": "^9.1.0",
"@angular/common": "^9.0.4",
"@angular/compiler": "^9.0.4",
"@angular/core": "^9.0.4",
"@angular/flex-layout": "^9.0.0-beta.28",
"@angular/forms": "^9.0.4",
"@angular/localize": "^9.0.4",
"@angular/platform-browser": "^9.0.4",
"@angular/platform-browser-dynamic": "^9.0.4",
"@angular/platform-server": "^9.0.4",
"@angular/router": "^9.0.4",
"@aspnet/signalr": "^1.1.4",
"@mat-datetimepicker/core": "^3.0.0",
"@ng-bootstrap/ng-bootstrap": "^4.2.1",
"@ngrx/effects": "^8.0.1",
"@ngrx/entity": "^8.0.1",
"@ngrx/router-store": "^8.0.1",
"@ngrx/store": "^8.0.1",
"@ngrx/store-devtools": "^8.0.1",
"@ngx-loading-bar/core": "^4.2.0",
"@ngx-translate/core": "^11.0.1",
"@types/lodash": "^4.14.134",
"angular-in-memory-web-api": "^0.8.0",
"angular2-permission": "^0.1.3",
"angular2-promise-buttons": "^4.0.0",
"chart.js": "^2.8.0",
"chartist": "^0.11.2",
"classlist.js": "^1.1.20150312",
"core-js": "^3.1.4",
"hammerjs": "^2.0.8",
"highlight.js": "^9.15.8",
"jwt-decode": "^2.2.0",
"lodash": "^4.17.11",
"material-design-icons": "^3.0.1",
"moment": "^2.24.0",
"ng-inline-svg": "^8.4.1",
"ng2-jalali-date-picker": "^2.2.7",
"ngrx-store-freeze": "^0.2.4",
"ngx-clipboard": "^12.1.0",
"ngx-daterangepicker-material": "^2.1.3",
"ngx-highlightjs": "^3.0.3",
"ngx-material-file-input": "^1.1.1",
"ngx-perfect-scrollbar": "^8.0.0",
"ngx-permissions": "^7.0.2",
"ngx-toastr": "^10.0.4",
"object-path": "^0.11.4",
"rxjs": "^6.5.2",
"tslib": "^1.10.0",
"web-animations-js": "^2.3.1",
"zone.js": "~0.10.2"
},
"devDependencies": {
"@angular-devkit/build-angular": "^0.900.4",
"@angular/cli": "^9.0.4",
"@angular/compiler-cli": "^9.0.4",
"@angular/language-service": "^9.0.4",
"@angular/material": "^9.1.0",
"@angular/material-moment-adapter": "^9.1.0",
"@ngrx/schematics": "^8.0.1",
"@types/chartist": "^0.9.46",
"@types/highlight.js": "^9.12.3",
"@types/jasmine": "~3.3.13",
"@types/jasminewd2": "~2.0.6",
"@types/node": "~12.0.8",
"@types/object-path": "^0.11.0",
"codelyzer": "^5.1.0",
"jasmine-core": "~3.4.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "^4.1.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "^2.0.5",
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.2",
"protractor": "~5.4.2",
"ts-node": "~8.2.0",
"tslint": "~5.17.0",
"typescript": "^3.6.4",
"webpack-bundle-analyzer": "^3.3.2"
}
最佳答案
这是从 Angular 9 开始的 NGRX Store 和 Ivy 运行时的问题
这个问题在这里得到了最好的解释:https://github.com/ngrx/platform/issues/2109
当前的解决方法(2020 年 3 月 16 日)是禁用两者
strictStateImmutability and strictActionImmutability
在你的 StoreModule 元缩减器中
EffectsModule.forRoot([AuthEffects]),
StoreModule.forRoot(reducers,
{ metaReducers,
runtimeChecks: {
strictStateImmutability: false,
strictActionImmutability: false,
}
}
),
当然,这是一种解决方法,并不能解决问题。 NGRX 当前存在一个问题 https://github.com/ngrx/platform/issues/2404
关于javascript - 类型错误: Cannot assign to read only property 'tView' of object '[object Object]' in angular 9. 0.4,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60464978/