升级到Preview9。
但是当我尝试分离View和Model时,遇到任何错误吗?
RAZORGENERATE:错误RZ3008:标记助手无法定位标记名称 “ .ViewCustomerModel”,因为它包含“ <” 字符。
public class ViewCustomerModel: ComponentBase
{
[Inject]
protected IDataService Data {get;set;}
[Parameter]
public Guid CustomerId {get;set;}
public Customer Customer {get;set;}
protected override async Task OnInitializedAsync()
{
await Load();
}
private async Task Cancel() => await Load();
private async Task Load()
{
Customer = await Data.Load<Customer>(CustomerId);
}
private async Task Save(EditContext editContext)
{
if (editContext.Validate())
{
await Data.Save<Customer>(Customer);
}
}
}
答案 0 :(得分:0)
根据MSFT https://github.com/aspnet/AspNetCore/issues/13881
您总是需要一个名称空间,需要将类包装在一个名称空间中。