我正在研究 Blazor POC 并被困在路由上。我已经在页面上实现了一些路由,但是如果未配置某些路由并尝试从浏览器加载而不是仅在浏览器上获取“正在加载...”文本
App.razor 文件下方
<Router AppAssembly="@typeof(Program).Assembly">
<Found Context="routeData">
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
</Found>
<NotFound>
@*<LayoutView Layout="@typeof(BlazorWorkshop.Web.Client.Pages.Error404)">
<p>Sorry, there's nothing at this address.</p>
</LayoutView>*@
<p>Sorry, there's nothing at this address.</p>
</NotFound>
Index.html 在下面给出
<body id="page-top">
<app>
Loading...
</app>
<script src="_framework/blazor.webassembly.js"></script>
<script>navigator.serviceWorker.register('service-worker.js');</script>
在控制台中出现错误:
净::ERR_ABORTED 404
获取脚本时收到错误的 HTTP 响应代码 (404)。
未捕获(承诺)类型错误:无法使用脚本('https://localhost:44336/product/service-worker.js')为范围('https://localhost:44336/product/')注册 ServiceWorker:获取脚本时收到错误的 HTTP 响应代码 (404)。