C#Blazor这是可行的,但我有错误
也许我做错了什么,或者VisualStudio出了问题,请建议 错误是:C#Blazor这是可行的,但我有错误,c#,progressive-web-apps,blazor,C#,Progressive Web Apps,Blazor,也许我做错了什么,或者VisualStudio出了问题,请建议 错误是: "Severity Code Description Project File Line Suppression State Error CS0115 'TechProfile.OnInitializedAsync()': no suitable method found to override 程序按预期工作,但如果错误是真的,我不希望出现错误。另外,如果有人知道如何根据我的代码查
"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);
}
}
您的组件是从
TechModel
下降的,它不是直接或间接从ComponentBase下降的,因此没有替代方法。您的组件是从TechModel
下降的,它不是直接或间接从ComponentBase下降的,因此没有替代方法
public class TechModel
{
public string TechName { get; set; } = "";
public string TechID { get; set; } = "";
public string TechPhoneNumber { get; set; } = "";
public string TechEmail { get; set; } = "";
}