有一个文件(也许是 main.js),我可以在其中为所有请求设置 baseUrl?
我从奥里利亚开始,很抱歉这是一个愚蠢的问题。
最佳答案
使用withBaseUrl configuration option在 HttpClient 上。
这是来自 http://www.elanderson.net/2015/09/aurelia-with-asp-net-5-and-web-api/ 的示例在 App 类中。
import {HttpClient} from 'jspm_packages/github/aurelia/fetch-client@0.1.2/aurelia-fetch-client.js';
import 'fetch';
@inject(HttpClient)
export class App{
constructor(http){
http.configure(config => {
config
.useStandardConfiguration()
.withBaseUrl('http://localhost:14830/api/');
});
this.http = http;
}
}
关于javascript - Aurelia 框架的请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40342168/