用Blazor碰到了问题,在页面上想接收id参数的值,但是报错了。
InvalidOperationException: No writer was cached for the property 'Id' on type 'BlazorApp2.Pages.Index'.
@page "/{id}"
@code {
[Parameter]
public string? Id { get; set; }
}
报错了。
原来报错InvalidOperationException: Object of type 'BlazorApp2.Pages.Index' has a property matching the name 'id', but it does not have [ParameterAttribute] or [CascadingParameterAttribute] applied. 是因为没有加[Parameter]标签,但是加了报这个新的错,知道是什么原因吗?