我的 Blazor 应用程序与 Blazored-modal 存在一些问题。如果我尝试在有人访问该应用程序后立即显示模态弹出窗口,则无法正确显示模态弹出窗口并且控制台显示此消息:
Failed to load resource: the server responded with a status of 404 (Not Found) blazored-modal.css:1
任何其他弹出窗口都正确显示,并且控制台中不再出现错误消息。
一切设置正确:
配置服务:
public void ConfigureServices(IServiceCollection services)
{
services.AddRazorPages();
services.AddServerSideBlazor();
services.AddSingleton<WeatherForecastService>();
services.AddBlazoredModal();
}
_进口:
@using Blazored.Modal
@using Blazored.Modal.Services
应用剃须刀:
<CascadingBlazoredModal>
<Router AppAssembly="@typeof(Program).Assembly">
<Found Context="routeData">
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
</Found>
<NotFound>
<LayoutView Layout="@typeof(MainLayout)">
<p>Sorry, there's nothing at this address.</p>
</LayoutView>
</NotFound>
</Router>
_Host.cshtml
@page "/"
@namespace StampaManualeEtichetteAggiuntive.Pages
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@{
Layout = null;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link href="_content/Blazored.Modal/blazored-modal.css" rel="stylesheet" />
<title>StampaManualeEtichette</title>
<base href="~/" />
<link rel="stylesheet" href="css/bootstrap/bootstrap.min.css" />
<link href="css/site.css" rel="stylesheet" />
</head>
<body>
<app>
<component type="typeof(App)" render-mode="ServerPrerendered" />
</app>
<div id="blazor-error-ui">
<environment include="Staging,Production">
An error has occurred. This application may no longer respond until reloaded.
</environment>
<environment include="Development">
An unhandled exception has occurred. See browser dev tools for details.
</environment>
<a href="" class="reload">Reload</a>
<a class="dismiss"></a>
</div>
<script src="_framework/blazor.server.js"></script>
<script src="_content/Blazored.Modal/blazored.modal.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-
awesome/5.15.1/css/all.min.css">
<script src="css/font-awesome/js/all.min.js"></script>
</body>
</html>
在我的 Index.razor
[CascadingParameter] public IModalService Modal { get; set; }
有人可以帮我解决问题吗?