簡體   English   中英

在 Angular 中的 URL 端點中使用雙點用於多個環境

[英]Using double dots in a URL endpoint in Angular for more than one environment

我正在使用 Angular8、Java8、Maven 和 Tomcat 8.0,並且我想通過單個構建部署三個環境。 Angular 是一個處理“一個構建,一個環境”的應用程序。 可以對其進行調整以一次運行更多環境,但對我來說,這沒有意義。

Normally, in a URL you put localhost or any other URL and build the angular project so the dist file will be saved with the chosen URL. 這次我只使用..(雙點),例如 ../rest/endpoint,它也在許多環境中工作。 如果我構建 angular 項目並且 URL 是動態設置的,則雙點技巧有效。 因此,使用雙點技巧,我的應用程序可以在www.website.com/rest/endpoint以及 localhost:8080/rest/endpoint 上運行。

有人可以向我解釋這個雙點技巧嗎?

I think that you encapsulate REST API interaction with your backend to some Angular service that will have logic of correct backend URL construction. 在此服務中,您可以使用環境變量使用 ( https://angular.io/guide/build ) 構建后端 URL 以改變您的構建環境。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM