小编Emb*_*yub的帖子

在 blazor 中选择框绑定

我试图将模型中的“CountryId”绑定到 blazor 中 SelectList 的选定项目的值。所有国家/地区项目都在一个列表中,如 {CountryId, CountryName} 对象。我这样做的代码是这样的:

    <InputSelect @bind-Value="model.ByCountryId" class="form-control">
        @if (model?.Countries != null)
        {
           @foreach (var cnt in model.Countries)
           {
               <option value="@cnt.Id">@cnt.Name</option>
           }
        }
     </InputSelect>
Run Code Online (Sandbox Code Playgroud)

和代码块:

@code {

BrandModel model = new BrandModel();

protected override async Task OnInitializedAsync()
{
    model = new BrandModel
    {
        Id = 19,
        ByCountryId = 1,
        Countries = new List<ent.Country>
            {
                new ent.Country { Id = 1, Name = "Azerbaijan" },
                new ent.Country { Id = 2, Name = "Turkey" }
            },
        IsActive = …
Run Code Online (Sandbox Code Playgroud)

c# asp.net asp.net-core blazor

26
推荐指数
2
解决办法
5万
查看次数

Blazor 页面中的不同 css 文件

我想对Blazor 中的不同布局和页面使用不同的 css 文件。因此,我不想将所有 css 文件直接导入 index.html,而是在需要时导入每个页面或布局。

<link href="css/bootstrap/bootstrap.min.css" rel="stylesheet" />
<link href="css/site.css" rel="stylesheet" />

<link href="lib/font-awesome/css/all.min.css" rel="stylesheet" />
<link href="customCss/adminpanle.min.css" rel="stylesheet" />
Run Code Online (Sandbox Code Playgroud)

因此,我在底部添加了 2 个链接,我只想将它们添加到一个布局中,而不是添加到 index.html 文件中。问题是:如何将 css 添加到 blazor 页面(.razor 文件)?

提前致谢!

single-page-application blazor

6
推荐指数
1
解决办法
6976
查看次数