(11/30)Learning Blazor Together: Arbitrary Attributes
Currently `MyButton` has 3 `[Parameter]`s. If we need to add more, we would have to define new `[Parameter]`s again. To avoid constantly updating this Component, let's use Blazor's `@attribute`.
Currently `MyButton` has 3 `[Parameter]`s. If we need to add more, we would have to define new `[Parameter]`s again. To avoid constantly updating this Component, let's use Blazor's `@attribute`.
Now we have an interface to input log entries. But logs are meant to be written every day; how can just one be enough? Let's add a blog.
If we want to add a button to clear the `form` data, the fastest way is to add a `type=”reset”` button. At this point, we use two buttons, which can utilize the core concept of Blazor: component encapsulation.
Now every time you start the project, the default path will be `/`, but we currently don't have a Component using this route. It's a bit troublesome to manually switch to `Post`. Additionally, the Menu icon doesn't match its name. Let's adjust it.
Services you create yourself must be registered in Startup.cs (Blazor Server) or Program.cs (Blazor WebAssemlby), but some basic services don't need to be created by yourself.
Yesterday I saw that the code in `FetchData.razor` was too long. For convenience, we extracted the `@code` section into a separate file.
The question is, how does Blazor know that WeatherForecastService can be invoked here?
Most Windows Forms applications I encounter have no or extremely low unit test coverage. And they are often difficult to maintain, with hundreds or even thousands of lines of code behind various Form classes in the project, but it doesn't have to be that way.
Since the author used ASP.NET Core API + Blazor Server initially, the demonstration will be based on Blazor Server. After researching Blazor WebAssembly, the insights will be supplemented later.
After downloading Visual Studio, first create a Blazor solution and establish a Blazor Server project inside it. You can choose the project location yourself. (Note: The new version of Visual Studio has separated the project templates for Blazor Server and Blazor WebAssembly, making it more intuitive.)