.Net Core-TagHelpers-Environment

當咱們新建一個.net core項目時,發現頁面中有個奇怪的TagHelper元素,以下:
    <environment names="Development">
        <link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.css" />
        <link rel="stylesheet" href="~/css/site.css" />
    </environment>
    <environment names="Staging,Production">
        <link rel="stylesheet" href=" https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.6/css/bootstrap.min.css"
              asp-fallback-href="~/lib/bootstrap/dist/css/bootstrap.min.css"
              asp-fallback-test-class="sr-only" asp-fallback-test-property="position" asp-fallback-test-value="absolute" />
        <link rel="stylesheet" href="~/css/site.min.css" asp-append-version="true" />
    </environment>
 
environment是什麼呢?
他表示處於不一樣的運行環境能夠調用不一樣的文件。
上例中,names爲「Development」的表示當處在開發環境下要調用的文件。
names爲Staging,Production表示處在Staging或者生產環境下要調用的文件。Link中的屬性asp-fallback-href表示若是加載失敗了要調用的文件路徑。
相關文章
相關標籤/搜索