我在我的Stackbliz应用程序中添加了import { Component, OnInit } from '@angular/core';
import {Location} from '@angular/common';
import {Openrouteservice} from '/openrouteservice-js/dist/ors-js-client';
@Component({
selector: 'app-event-plan',
templateUrl: './event-plan.component.html',
styleUrls: ['./event-plan.component.scss']
})
export class EventPlanComponent implements OnInit {
constructor(private _location: Location) {
console.log("++++")
console.log(Openrouteservice)
}
ngOnInit() {
}
backClicked() {
this._location.back();
}
}
,但无法正常运行。
组件看起来像:
{{1}}
我的问题是它没有被加载。我在依赖项部分将其添加为依赖项。
我将项目公开了,这里是URL-https://stackblitz.com/edit/angular-micwge?file=src%2Fapp%2Fevent-plan%2Fevent-plan.component.ts
答案 0 :(得分:1)
您将不得不更改import
库的方式。您import
当前的方法是从库中查找命名导出。
如果您的allowSyntheticImports
中有esModuleInterop
和tsconfig.json
,请使用以下方法:
import Openrouteservice from 'openrouteservice-js';
否则:
import * as Openrouteservice from 'openrouteservice-js';