C# 布雷泽 这有效,但我收到错误



也许我做错了什么,或者VisualStudio正在采取行动,请指教...

错误是:

"Severity   Code    Description Project File    Line    Suppression State
Error   CS0115  'TechProfile.OnInitializedAsync()': no suitable method found to override

该程序按预期工作,但如果错误是真错误,我不希望弹出错误。 如果有人知道一种基于我的代码查看 Blazored.LocalStorage 的方法,我也请告知 我很想知道一种方法可以将其放在单独的 cs 文件中并调用它一次,而不是继续设置它。

好的,这是我的剃须刀组件

@page "/profile/techprofile/techinfo"
@using TechHelper.Model
@inherits TechModel
@inject Blazored.LocalStorage.ILocalStorageService oLocalStore

<h3>Technician Profile</h3>

<table id="TechProfile" class="ProfileTable">
<thead colspan="2"> Profile Information </thead>
<tr>
<td>Full Name: </td>
<td><input type="text" id="TechName" class="inputfield" @bind-value="@TechName" /></td>
</tr>
<tr>
<td>Standard ID: </td>
<td><input type="text" id="StandardID" class="inputfield" @bind-value="@TechID" /></td>
</tr>
<tr>
<td>Email Address: </td>
<td><input type="text" id="TechEmail" class="inputfield" @bind-value="@TechEmail" /></td>
</tr>
<tr>
<td>Phone Number: </td>
<td><input type="text" id="TechPhoneNumber" class="inputfield" @bind="@TechPhoneNumber" />
</td>
</tr>
<tr>
<td colspan="2"><div align="center"><input class="techSubmit" type="button" 
@onclick="SaveProfile" value ="Save Profile Information" /></div></td>
</tr>
</table>
<span>@Message</span>

@code {

string Message = "";
protected override async Task OnInitializedAsync()
{
TechName = await oLocalStore.GetItemAsync<string>("TechnicianName");
TechID = await oLocalStore.GetItemAsync<string>("TechnicianID");
TechPhoneNumber = await oLocalStore.GetItemAsync<string>("TechnicianPhoneNumber");
TechEmail = await oLocalStore.GetItemAsync<string>("TechnicianEmail");
}
public async void SaveProfile()
{
Message = "Profile Data Saved";
await oLocalStore.SetItemAsync("TechnicianName", TechName);
await oLocalStore.SetItemAsync("TechnicianID", TechID);
await oLocalStore.SetItemAsync("TechnicianPhoneNumber", TechPhoneNumber);
await oLocalStore.SetItemAsync("TechnicianEmail", TechEmail);
}
}

这是我的技术模型.cs - 我添加了 = "; 因为错误试图查看它是否会关闭它。

public class TechModel
{
public string TechName { get; set; } = "";
public string TechID { get; set; } = "";
public string TechPhoneNumber { get; set; } = "";
public string TechEmail { get; set; } = "";
}

您的组件是从TechModel衍生而来的,该不会直接或间接地从组件库衍生而来,因此没有可以覆盖的方法。

最新更新