【发布时间】:2021-02-02 23:48:49
【问题描述】:
此处页面组件
@page "/student"
<h3>Student List</h3>
<h5>@StudentsList</h5>
<StudentDetail StudentName="Something New" ButtonClicked="@Save"></StudentDetail>
<h5>This is second</h5>
<h5>@SaveMessage</h5>
@code {
public string StudentsList { get; set; }
private string SaveMessage { get; set; }
protected override async Task OnInitializedAsync()
{
StudentsList = "ASD DSA KDS CFA";
}
private void Save(MouseEventArgs e)
{
SaveMessage = "Operation Saved.";
}
}
这是StudentDetail
<h3>Student Detail for @StudentName</h3>
<button class="btn btn-primary" @onClick="ButtonClicked">Click Me!</button>
@code {
[Parameter]
public string StudentName { get; set; }
[Parameter]
public EventCallback<MouseEventArgs> ButtonClicked { get; set; }
}
我在服务器端和客户端都试过这个。当我点击“点击我!”按钮,绝对没有任何反应。我做错了什么?
这些是进口产品
@using System.Net.Http
@using System.Net.Http.Json
@using Microsoft.AspNetCore.Authorization
@using Microsoft.AspNetCore.Components.Authorization
@using Microsoft.AspNetCore.Components.Forms
@using Microsoft.AspNetCore.Components.Routing
@using Microsoft.AspNetCore.Components.Web
@using Microsoft.JSInterop
@using BlazorApp4
@using BlazorApp4.Shared
【问题讨论】:
标签: c# components blazor blazor-server-side blazor-client-side