微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Blazored Modal不会出现

如何解决Blazored Modal不会出现

几天前,我更新了blazored.Modal,但现在我的PopUp无法正常工作。我调整了代码,但仍然无法使用,也找不到问题。我真的不知道该怎么办,我清除了缓存并使用了其他浏览器,但仍然无法正常工作。

代码: App.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>

_Imports.razor

@using blazored
@using blazored.Modal
@using blazored.Modal.Services

_Host.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.razor)的页面

@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.razor)

@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>

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?