Часы на странице бритвы в Blazor 8C#

Место общения программистов C#
Гость
Часы на странице бритвы в Blazor 8

Сообщение Гость »


Страница бритвы с часами

Код: Выделить всё

Current



function updateClock() {
var now = moment().format('YYYY-MM-DD HH:mm:ss');
document.getElementById('clock').innerText = now;
}

updateClock();

setInterval(updateClock, 1000);


procram.cs : grobal rendering mode setting for SSR

Код: Выделить всё

app.MapRazorComponents()
.AddInteractiveServerRenderMode();
And installed, moment.js library from Nuget.
But the clock only works after refeshing manually.
I tried

Код: Выделить всё

    [Inject]
private IJSRuntime JSRuntime { get; set; }

protected override async Task OnInitializedAsync()
{
await JSRuntime.InvokeVoidAsync("setInterval");
}
or

Код: Выделить всё

app.MapRazorComponents()
.AddAdditionalAssemblies();
But nothing changed.
How can I make it work automatically?


Источник: https://stackoverflow.com/questions/781 ... n-blazor-8

Вернуться в «C#»