繁体   English   中英

将两个URL合并为angular2 - ionic2中的一个

[英]combine two URL into one in angular2 - ionic2

我试图将两个网址组合成一个网址。

let url = "http://example.com/public/";

我有来自API的路径"/samples/leads/Import_Leads_Sample.csv"文件。 我在一个下标中将此作为文件filepath现在filepath保存

 filepath: "/samples/leads/Import_Leads_Sample.csv"

我希望将它们组合在一起并形成一个URL。

let url = "http://example.com/public/samples/leads/Import_Leads_Sample.csv"

将文件路径存储在变量中并组合这两个变量。

let url = "http://example.com/public/";
let filepath = Object.filepath; // equals "/samples/leads/Import_Leads_Sample.csv"

let finalUrl = url + filepath.substr(1); // substr(1) to remove the '/' and avoid having a final url with '//' in it

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM