我正在学习打字稿(使用VS2015)并停留在导出/导入模块。 我收到错误“模块名称”../TypeFiles/Address“尚未加载上下文”。
我创建了两个类Customer&地址并尝试在客户类中导入地址。
import {Address} from "../TypeFiles/Address";
class Customer {
public adderessObj: Address = new Address();
private _CustomerName: string = "";
public set CustomerName(value: string) {
if (value.length == 0) {
throw "Customer name is required.";
}
this._CustomerName = value;
}
public get CustomerName(): string {
return this._CustomerName;
}
}
export class Address {
public Street: string = "";
public City: string = "";
public Pincode: string = "";
}
我下载了requirejs(RequireJS 2.3.2)并将其添加到我的html页面中。
<script src="Scripts/require.js"></script>
<script type="text/javascript" src="TypeFiles/Customer.js"></script>