o.Subject 不是构造函数 - Angular 10 [英] o.Subject is not a constructor - Angular 10

查看:45
本文介绍了o.Subject 不是构造函数 - Angular 10的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Ng serveng build --prod 命令工作正常,但是当我在服务器上部署应用程序时,会出现以下错误:-

Ng serve and ng build --prod command working fine, but when I deploy the app on serve that time below error occurs:-

TypeError: o.Subject is not a constructor
at new e (vendor-esnext.js:1)
at Object.useFactory (vendor-esnext.js:1)
at Object.i [as factory] (vendor-esnext.js:1)
at Xo.hydrate (vendor-esnext.js:1)
at Xo.get (vendor-esnext.js:1)
at Jf.get (vendor-esnext.js:1)
at Object.get (vendor-esnext.js:1)
at Gn (vendor-esnext.js:1)
at Module.Sl (vendor-esnext.js:1)
at Mn.e.ɵfac [as factory] (vendor-esnext.js:1)


tsconfig.base.json

{"compilerOptions": {
"baseUrl": "",
"allowSyntheticDefaultImports": true,
"declaration": false,
"downlevelIteration": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": [
  "dom",
  "es2017"
],
"module": "esnext",
"moduleResolution": "node",
"sourceMap": true,
"target": "ESNext",
"paths": {
  "@angular/*": [
    "node_modules/@angular/*"
  ]
}},"include": [
"src/**/*.ts",
"node_modules/ng4-fittext/*.d.ts"],"exclude": [],"compileOnSave": false,}

推荐答案

这个问题将在 Angular 10 及更高版本中解决,如果你将 import 语句替换为主题如下.

The problem will be solved in Angular 10 and later if you replace the import statement of subject as below.

替换:

import { Subject } from "rxjs/Subject";

与:

import { Subject } from "rxjs";

这篇关于o.Subject 不是构造函数 - Angular 10的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆