I have a page which takes a string bookingReference as its route parameter Booking/{bookingReference}.
This page is the parent component, with a child component inside where booking details are managed. The child component calls back to the parent when booking details are updated.
@page "/Booking/{bookingReference}"
<div class="header">
<h1> @Booking.BookingReference </h1>
</div>
<div>
<BookingDetails Booking="Booking" OnUpdateBooking="UpdateBooking" />
</div>
@code {
[Parameter]
public string BookingReference { get; set; }
private Booking Booking { get; set; }
void UpdateBooking(Booking booking)
{
Booking …Run Code Online (Sandbox Code Playgroud) 当我在 Visual Studio 中打开 Blazor 解决方案时,Intellisense 将显示对 Blazor 组件的引用的错误错误,并将成功编译。
例如,在我的许多类中,我注入了ILogger<BlazorComponent>一个需要记录的组件,在本例中是我的Details.razor组件:
public partial class DetailsBase : ComponentBase
{
[Inject]
protected ILogger<Details> Logger { get; set; }
// etc etc...
}
Run Code Online (Sandbox Code Playgroud)
但是,Intellisense 始终显示 未找到 的错误Details。它将成功编译,但虚假错误将保留,直到您导航到该特定文件(Details.razor在本例中)并且 Intellisense 拾取它。
这些虚假错误使我的调试窗口变得混乱,我想停止它们,而不必不断单击以转到文件以使其被 Intellisense 识别。
我可以启用某种设置来确保 Intellisense 检查这些文件吗?或者有什么东西比 Intellisense 更适合 Blazor?
我有一个 Blazor 组件,需要将布尔值传递给其子组件,以在提交时禁用表单提交按钮。
<EditForm Model="Model" OnValidSubmit="SubmitSearch">
<div class="panel-body">
<ChildComponent IsSubmitting="@IsSubmitting"/>
</div>
</EditForm>
Run Code Online (Sandbox Code Playgroud)
我的子组件只是一系列带有提交按钮的输入
<div>
// inputs etc.
<span class="pull-left">
<button class="btn btn-success" type="submit" disabled="@IsSubmitting">
Submit Search
</button>
</span>
</div>
@code {
[Parameter]
public bool IsSubmitting { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我的提交方法像这样设置 IsSubmitting
public async void SubmitSearch()
{
IsSubmitting = true;
var result = await Service.GetStuff();
// do stuff with result
IsSubmitting = false;
}
Run Code Online (Sandbox Code Playgroud)
我注意到该按钮永远不会禁用。我是否缺少某种生命周期挂钩来在参数更新时触发重新渲染?
任何帮助表示赞赏。