【问题标题】:agm direction build type r erroragm 方向构建类型 r 错误
【发布时间】:2018-07-02 11:22:55
【问题描述】:

我正在使用 Angular 6 。 使用 ng serve 和 ng build 一切正常,但使用 ng build --prod 地图无法打开,并且控制台中有此 type r is not a constructor

我正在使用 agm 方向https://github.com/explooosion/Agm-Direction/

  <agm-map [latitude]="lat" [longitude]="lng" [zoom]="13">
      <agm-direction [waypoints]="waypoints" [origin]="origin" [destination]="destination">
      </agm-direction>
  </agm-map>


 this.origin = { lat: 18.544405, lng: 73.735341 };
    this.destination = { lat: 18.544405, lng: 73.735341 };
    this.waypoints = [
      {
        location: "18.532667,73.8276983"
      },
      {
        location: "18.533654,73.8235143"
      },
      {
        location: "18.523258, 73.762949"
      }
    ];

【问题讨论】:

  • 我创建了一个堆栈闪电战,但无法重新创建您的错误stackblitz.com/edit/angular-en2dya?file=app%2Fapp.component.ts 您能否从您的文件中添加更多代码?或者尝试将您的版本更新为演示中使用的版本。
  • 这是一个构建错误,我不确定 stackblitz 将如何提供帮助

标签: javascript angularjs google-maps angular6


【解决方案1】:

我最近偶然发现了同样的错误,原来错误是由Ahead-of-Time (AOT) Compilation 引起的(在生产部署中默认启用

一种解决方案是禁用 AOT:

ng build --prod --aot false

另一种解决方案是等到此错误在Agm-Direction library 中得到解决

以下是解决此问题的更改列表:

1) 通过从 tsconfig.es5.json 中删除以下内容来禁用 FESM

"flatModuleOutFile": "agm-direction.js",
"flatModuleId": "agm-direction"

2) 通过替换行修改gulpfile.js(用于copy:build 任务)

return gulp.src([`${buildFolder}/**/*`, `!${buildFolder}/**/*.js`])

return gulp.src([`${buildFolder}/**/*`])

【讨论】:

    猜你喜欢
    • 2020-11-30
    • 2020-12-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-01
    • 1970-01-01
    • 2019-10-22
    相关资源
    最近更新 更多