1
通過Systemjs獲取請求不會將擴展.js添加到url。無法在TypeScript和Systemjs中加載具有擴展js的模塊
這些都是我的打字稿類
customer.ts
import {Address} from "./Address";
export class Customer {
private _customerName: string = "";
public CustomerAddress: Address = new Address();
public set CustomerName(value: string) {
if (value.length == 0) {
throw "Customer Name is required";
}
this._customerName = value;
}
public get CustomerName() {
return this._customerName;
}
Validate(): boolean {
return this._customerName != '';
}
}
address.ts使用
export class Address {
public Street1: string = "";
}
以下Systemjs初始化代碼
System.config({
defaultExtension: 'js',
});
System.import("Customer.js").then(function (exports) {
var cust = new exports.Customer();
});
Customer.js是LOA ded成功但Address.js不是。
爲Address.js的GET請求不包含的.js extention 導致以下控制檯請求
GET http://localhost:65401/Address 404 (Not Found).
我試圖更新customer.ts下面的代碼下面
import {Address} from "./Address.js";
但它在語法上是錯誤的,它在VS2013中顯示錯誤。
如何強制Systemjs將擴展「.js」添加到GET請求。
謝謝
爲我工作。謝謝 !! – Mayank