18
當測試一些JavaScript代碼時,從打字稿文件轉譯出來時出現以下錯誤。錯誤:* .default不是構造函數
我該怎麼做才能解決這個問題?
以下是錯誤:
Error: _mapAction2.default is not a constructor
這裏是導致錯誤的代碼行:
var mapAction = new MapAction(MapActionType.POLYGONDRAGGED, []);
這裏原來打字稿文件地圖action.ts :
import { IMapAction} from './imap-action';
import { MapActionType } from './map-action-type.enum';
import {LatLngLiteral} from 'angular2-google-maps/core';
export class MapAction implements IMapAction{
type: MapActionType;
paths: Array<LatLngLiteral>;
constructor(mapActionType: MapActionType, paths: Array<LatLngLiteral>){
this.type = mapActionType;
this.paths = paths;
}
public getType(): MapActionType{
return this.type;
}
public getPaths(): Array<LatLngLiteral>
{
return this.paths;
}
}
這裏是transpiled的.js文件地圖action.js:
"use strict";
class MapAction {
constructor(mapActionType, paths) {
this.type = mapActionType;
this.paths = paths;
}
getType() {
return this.type;
}
getPaths() {
return this.paths;
}
}
exports.MapAction = MapAction;
//# sourceMappingURL=map-action.js.map
提前感謝!
或替代,進口'{}地圖行動從」 /無出口默認 – Ksyqo
map_action_file''謝謝YEV,我合併所有MAP_ACTION相關文件合併成一個,然後@ Ksygo的評論修正了錯誤! – ChristopherMortensen
缺乏{}讓我如此:從'./Frak'導入{Frak};'修復了它。謝謝。 – RyanNerd