父组件
<ChildComponent text="@parseString"/>
@code{
public string parseString(string text)
{
return text;
}
}子组件
<MudText>@text</MudText>
@code{
[Parameter]
public string text { get; set; }
}我只想将函数结果从父组件传递给我的子组件,但是我得到了这个异常。
Unhandled exception rendering component: Object reference not set to an instance of an object.发布于 2022-10-04 15:37:36
<ChildComponent text="@parseString("Hello world")" />
@code{
public string parseString(string text)
{
return text;
}
}或者:
<ChildComponent text="@parseString(Message)" />
@code{
private string Message => "Hello world";
public string parseString(string text)
{
return text;
}
}https://stackoverflow.com/questions/73950078
复制相似问题