【发布时间】:2020-05-12 15:06:12
【问题描述】:
在我的 Blazor 组件上,我接受一个参数:
@page "/plant/{PlantName}"
@code {
[Parameter]
public string PlantName { get; set; }
private TestGarden.Models.Plants pd = new PlantData().GetPlantInformation(PlantName);
}
在方法“GetPlantInformation”上,它表示“PlantName”-A field initializer cannot reference the non-static field, method, or property 'Plant.PlantName'
我无法将属性 PlantName 设为静态,否则 Blazor 将无法工作。那么如何使用这个属性作为方法参数呢?
【问题讨论】:
标签: c# asp.net-core blazor asp.net-blazor