账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    angular7 ng-zorro-antd 版本问题
    40
    0
    • 今天打开老项目运行起来报错,发现是版本问题,先升级了ts版本再升级angular版本,最后升级ng-zorro-antd的版本,升级后的package.json全部代码如下:

      {
        "name": "source",
        "version": "0.0.0",
        "scripts": {
          "ng": "ng",
          "start": "ng serve",
          "build": "ng build --configuration=production",
          "test": "ng test",
          "lint": "ng lint",
          "e2e": "ng e2e"
        },
        "private": true,
        "dependencies": {
          "@angular/animations": "^7.2.7",
          "@angular/common": "^7.2.7",
          "@angular/compiler": "^7.2.7",
          "@angular/core": "^7.2.7",
          "@angular/forms": "^7.2.7",
          "@angular/http": "^7.2.7",
          "@angular/platform-browser": "^7.2.7",
          "@angular/platform-browser-dynamic": "^7.2.7",
          "@angular/router": "^7.2.7",
          "core-js": "^2.5.4",
          "ng-zorro-antd": "^7.0.0-rc.3",
          "primeicons": "^1.0.0-beta.10",
          "primeng": "^6.1.4",
          "rxjs": "^6.4.0",
          "tslib": "^1.9.0",
          "zone.js": "~0.8.29"
        },
        "devDependencies": {
          "@angular-devkit/build-angular": "~0.13.0",
          "@angular/cli": "~7.3.3",
          "@angular/compiler-cli": "^7.2.7",
          "@angular/language-service": "^7.2.7",
          "@types/jasmine": "~2.8.6",
          "@types/jasminewd2": "~2.0.3",
          "@types/node": "~8.9.4",
          "codelyzer": "~4.2.1",
          "jasmine-core": "~2.99.1",
          "jasmine-spec-reporter": "~4.2.1",
          "karma": "~1.7.1",
          "karma-chrome-launcher": "~2.2.0",
          "karma-coverage-istanbul-reporter": "~2.0.0",
          "karma-jasmine": "~1.1.1",
          "karma-jasmine-html-reporter": "^0.2.2",
          "protractor": "~5.4.0",
          "ts-node": "~5.0.1",
          "tslint": "~5.9.1",
          "typescript": "^3.2.4"
        }
      }
      

    下面是angular.json全部代码

    
    ```
    {
      "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
      "version": 1,
      "newProjectRoot": "projects",
      "projects": {
        "source": {
          "root": "",
          "sourceRoot": "src",
          "projectType": "application",
          "prefix": "app",
          "schematics": {},
          "architect": {
            "build": {
              "builder": "@angular-devkit/build-angular:browser",
              "options": {
                "outputPath": "dist/source",
                "index": "src/index.html",
                "main": "src/main.ts",
                "polyfills": "src/polyfills.ts",
                "tsConfig": "src/tsconfig.app.json",
                "assets": [
                  "src/favicon.ico",
                  "src/assets",
                  {
                    "glob": "**/*",
                    "input": "./node_modules/@ant-design/icons-angular/src/inline-svg/",
                    "output": "/assets/"
                  }
                ],
                "styles": [
                  "node_modules/ng-zorro-antd/ng-zorro-antd.min.css",
                  "node_modules/ng-zorro-antd/src/ng-zorro-antd.min.css",
                  "src/styles.css",
                  "node_modules/primeicons/primeicons.css",
                  "node_modules/primeng/resources/themes/nova-light/theme.css",
                  "node_modules/primeng/resources/primeng.min.css"
                ],
                "scripts": []
              },
              "configurations": {
                "production": {
                  "fileReplacements": [
                    {
                      "replace": "src/environments/environment.ts",
                      "with": "src/environments/environment.prod.ts"
                    }
                  ],
                  "optimization": true,
                  "outputHashing": "all",
                  "sourceMap": false,
                  "extractCss": true,
                  "namedChunks": false,
                  "aot": true,
                  "extractLicenses": true,
                  "vendorChunk": false,
                  "buildOptimizer": true
                }
              }
            },
            "serve": {
              "builder": "@angular-devkit/build-angular:dev-server",
              "options": {
                "browserTarget": "source:build"
              },
              "configurations": {
                "production": {
                  "browserTarget": "source:build:production"
                }
              }
            },
            "extract-i18n": {
              "builder": "@angular-devkit/build-angular:extract-i18n",
              "options": {
                "browserTarget": "source:build"
              }
            },
            "test": {
              "builder": "@angular-devkit/build-angular:karma",
              "options": {
                "main": "src/test.ts",
                "polyfills": "src/polyfills.ts",
                "tsConfig": "src/tsconfig.spec.json",
                "karmaConfig": "src/karma.conf.js",
                "styles": [
                  "node_modules/ng-zorro-antd/ng-zorro-antd.min.css",
                  "node_modules/ng-zorro-antd/src/ng-zorro-antd.min.css",
                  "src/styles.css"
                ],
                "scripts": [],
                "assets": [
                  "src/favicon.ico",
                  "src/assets"
                ]
              }
            },
            "lint": {
              "builder": "@angular-devkit/build-angular:tslint",
              "options": {
                "tsConfig": [
                  "src/tsconfig.app.json",
                  "src/tsconfig.spec.json"
                ],
                "exclude": [
                  "**/node_modules/**"
                ]
              }
            }
          }
        },
        "source-e2e": {
          "root": "e2e/",
          "projectType": "application",
          "architect": {
            "e2e": {
              "builder": "@angular-devkit/build-angular:protractor",
              "options": {
                "protractorConfig": "e2e/protractor.conf.js",
                "devServerTarget": "source:serve"
              },
              "configurations": {
                "production": {
                  "devServerTarget": "source:serve:production"
                }
              }
            },
            "lint": {
              "builder": "@angular-devkit/build-angular:tslint",
              "options": {
                "tsConfig": "e2e/tsconfig.e2e.json",
                "exclude": [
                  "**/node_modules/**"
                ]
              }
            }
          }
        }
      },
      "defaultProject": "source"
    }
    ```
    
    • 现在使用命令:ng serve --open运行项目出现下面的错误

      D:\Java\frontEnd\femis\source>ng serve --open
      ** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
      
      Date: 2019-02-27T15:14:54.044Z
      Hash: 9498e00a8db5bee81c1a
      Time: 33716ms
      chunk {main} main.js, main.js.map (main) 1.85 kB [initial] [rendered]
      chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 92.3 kB [initial] [rendered]
      chunk {runtime} runtime.js, runtime.js.map (runtime) 6.08 kB [entry] [rendered]
      chunk {styles} styles.js, styles.js.map (styles) 2.65 MB [initial] [rendered]
      chunk {vendor} vendor.js, vendor.js.map (vendor) 327 kB [initial] [rendered]
      
      WARNING in ./node_modules/ng-zorro-antd/ng-zorro-antd.min.css (./node_modules/@angular-devkit/build-angular/src/angular-cli-files/plugins/raw-css-loader.js!./node_modules/postcss-loader/src??embedded!./node_modules/ng-zorro-antd/ng-zorro-antd.min.css)
      Module Warning (from ./node_modules/postcss-loader/src/index.js):
      Warning
      
      (1:3134) Replace text-decoration-skip: ink to text-decoration-skip-ink: auto, because spec had been changed
      
      WARNING in ./node_modules/ng-zorro-antd/src/ng-zorro-antd.min.css (./node_modules/@angular-devkit/build-angular/src/angular-cli-files/plugins/raw-css-loader.js!./node_modules/postcss-loader/src??embedded!./node_modules/ng-zorro-antd/src/ng-zorro-antd.min.css)
      Module Warning (from ./node_modules/postcss-loader/src/index.js):
      Warning
      
      (1:3134) Replace text-decoration-skip: ink to text-decoration-skip-ink: auto, because spec had been changed
      
      ERROR in src/app/shared/service/reflect-util.service.ts(3,10): error TS2305: Module '"D:/Java/frontEnd/femis/source/node_modules/@angular/core/src/render3"' has no exported member 'T'.

    网上搜索了下没有找到解决方法,这个问题要怎么解决了?

    2
    打赏
    收藏
    点击回答
        全部回答
    • 0
    • 一只只蛛 普通会员 1楼

      在使用 Angular 7 和 Ant Design 的 Zorro 前缀样式时,可能会遇到一些版本问题。这可能是因为Ant Design和其他库之间的版本冲突,或者你正在使用的版本与 Angular 的版本不兼容。

      解决这个问题的一种方法是使用 npm install 命令来安装最新的版本。这将确保你正在使用的版本是最新的。

      如果你遇到问题,可以尝试以下步骤:

      1. 首先,确保你的 Angular 和 Ant Design 的版本都在同一版本中。你可以使用 npm ls 命令来查看所有版本。

      2. 然后,尝试升级 Ant Design 的版本。你可以使用 npm upgrade antd 命令来升级。如果 Ant Design 的版本不支持你的 Angular 版本,你可能需要寻找一个兼容的版本。

      3. 如果你仍然遇到问题,你可能需要检查你的项目的依赖关系。你可以使用 npm list 命令来查看你的项目依赖的版本。

      4. 如果你仍然无法解决问题,你可能需要寻求专业的帮助。你可以向 Angular 的社区或者 Ant Design 的社区发帖寻求帮助。

      希望这些信息对你有所帮助!

    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部