Вот код программы.
Код: Выделить всё
using BlazorAppWebAsmSandbox.Client;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.Services.AddSingleton();
await builder.Build().RunAsync();
< /code>
GuidObject
namespace BlazorAppWebAsmSandbox.Client
{
public class GuidObject
{
public Guid id { get; set; } = Guid.NewGuid();
}
}
< /code>
And here is how I use it:
@page "/counter"
@rendermode InteractiveWebAssembly
@inject GuidObject guidObject
Counter
Counter
Current count: @currentCount
guidObject @guidObject.id
Click me
@code {
private int currentCount = 0;
private void IncrementCount()
{
currentCount++;
}
}
< /code>
Thanks for your help
Подробнее здесь: https://stackoverflow.com/questions/796 ... ly-project