【发布时间】:2020-04-29 04:13:48
【问题描述】:
我有以下剃须刀页面Index.cshtml:
@page "/Test/{value?}"
@model Test01.Areas.Test.Pages.IndexModel
<h1>Test</h1>
<h3>@Model.value</h3>
@(await Html.RenderComponentAsync<Test01.Components.Test>(RenderMode.ServerPrerendered))
索引.cshtml.cs:
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace Test01.Areas.Test.Pages
{
public class IndexModel : PageModel
{
[BindProperty(SupportsGet = true)]
public string value { get; set; } = "none";
public void OnGet()
{
}
}
}
带有剃须刀组件Test.razor:
<div>
<button class="btn btn-primary" @onclick="openModal">Open Modal</button>
</div>
@if (showModal)
{
<div class="modal" tabindex="-1" style="display:block" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title">Modal 1</h3>
<button type="button" class="close" @onclick="closeModal">
<span aria-hidden="true">X</span>
</button>
</div>
<div class="modal-body">
Modal Body
</div>
<div class="modal-footer">
Modal Footer
</div>
</div>
</div>
</div>
}
<hr />
@code {
protected bool showModal = false;
protected void openModal()
{
this.showModal = true;
}
protected void closeModal()
{
this.showModal = false;
}
}
当我调用没有值的页面时,例如:
当我单击打开模式按钮时,它按预期工作。
当我使用如下值调用页面时:
https://localhost:44306/Test/TestValue
当我单击打开模式按钮时没有任何反应。
感谢任何帮助!
【问题讨论】:
标签: asp.net asp.net-core razor-pages asp.net-core-3.1 razor-components