我几天前更新了Blazored.Modal,但现在我的PopUp无法工作。我调整了代码,但它仍然不起作用,我找不到问题。我真的不知道该怎么办了,我清空了缓存并使用了其他浏览器,但它仍然不起作用。
代码:应用程序Razor
<CascadingBlazoredModal>
<CascadingAuthenticationState>
<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>
</CascadingAuthenticationState>
</CascadingBlazoredModal>
_进口剃须刀
@using Blazored
@using Blazored.Modal
@using Blazored.Modal.Services
_主机.razor
@page "/"
@namespace FHNW_ASS.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" />
<title>FHNW-ASS</title>
<base href="~/" />
<link rel="stylesheet" href="css/bootstrap/bootstrap.min.css" />
<link href="css/site.css" rel="stylesheet" />
<link href="_content/Blazored.Modal/blazored-modal.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="_content/Blazored.Modal/blazored.modal.js"></script>
</body>
</html>
带有按钮的页面(Journal.rarzor(
@page "/Journal"
@using FHNW_ASS.Models
@using Microsoft.Extensions.Configuration
@using FHNW_ASS.Services
@inject IConfiguration _config
@inject IModalService modal
@inject IJournalService service
<div class="titleWrapper">
<div class="title">Journale eine go dreieeee</div>
<div class="flexbox">
<div class="content">
<button @onclick="@(() => modal.Show<JournalInputPage>("Add Journal Entry"))" class="additionButton">
<img class="plusIcon" src="/elements/plus-black-symbol.svg" />
Add Journal Entry
</button>
</div>
</div>
</div>
<hr />
<br />
<br />
应该弹出的页面(JournalInputPage.rarzor(
@using Microsoft.Extensions.Configuration
@using FHNW_ASS.Models
@inject FHNW_ASS.Models.FHNW_ASSContext _context
@inject IConfiguration _config
@inject IModalService modal
<!DOCTYPE html>
<head>
<link href="~/css/site.css" rel="stylesheet" />
</head>
<body>
<EditForm Model="@journalInputModel" OnValidSubmit="HandleValidSubmit">
<DataAnnotationsValidator />
<ValidationSummary />
<p>
<label for="title">Journal Title</label> <br />
<InputText id="title" @bind-Value="journalInputModel.JournalTitle" /> <br />
</p>
<p>
<label for="Week">Week</label> <br />
<InputNumber id="week" @bind-Value="journalInputModel.JournalWeek" /> <br />
</p>
<p>
<label for="content">Journal Content</label> <br />
@*<InputText id="content" @bind-Value="JournalInput.JournalContent" />*@
<textarea id="content" rows="10" cols="100" @bind="journalInputModel.JournalContent" />
</p>
@*<InputDate id="create" />
<InputDate id="edit" />*@
<button type="submit" class="submitButton">Submit</button>
</EditForm>
</body>
你想这就是你所需要的。
所以我找到了解决方案。我不知道为什么,但我的blazor.server.js不在_Host中。
<script src="_framework/blazor.server.js"></script>