[英]How to import and export module using systemjs in TypeScript?
有誰知道如何使用SystemScript在TypeScript中導出模塊? 我收到錯誤消息: TS1148 cannot compile modules unless the '--module' flag is provided
。
這是我的代碼; 動物
export class Animal {
color: string;
age: number;
constructor(color: string, age:number) {
this.color = color;
this.age = age;
}
add(animal: Animal) {
return new Animal(this.color + animal.color, this.age + animal.age);
}
}
狗狗
import {Animal} from './animal';
var animal1 = new Animal("red", 1);
var animal2 = new Animal("yellow", 2);
var animal3 = animal1.add(animal2);
console.log('Combine Two Animals' + animal3);
您可以在系統配置中指定打字稿編譯器選項。 在這里可以找到很多選擇
System.config({
typescriptOptions:{
module: 'system'
}
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.