[Blazor WASM] Lazing loading DLL
페이지 정보
작성자 sbLAB 댓글 0건 조회 5,882회 작성일 21-12-28 01:47본문
RadZen 라이브러리를 settings 메뉴에서만 로드할 경우 예제
- Radzen.Blazor 라이브러리 Nuget 설치 및 Client -> index.html 에 Radzen.Blazor 의 js/css 설정까지는 해주고..
Okpro.Client.csproj
<ItemGroup>
<BlazorWebAssemblyLazyLoad Include="Radzen.Blazor.dll" />
</ItemGroup>
Okpro.Client -> App.razor
@using Okpro.Client.Shared
@inject Microsoft.AspNetCore.Components.WebAssembly.Services.LazyAssemblyLoader AssemblyLoader
<Error>
<CascadingAuthenticationState>
<Router AppAssembly="@typeof(Program).Assembly"
AdditionalAssemblies="lazyLoadedAssemblies"
OnNavigateAsync="OnNavigation">
<Found Context="routeData">
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)">
<NotAuthorized>
</NotAuthorized>
<Authorizing>
</Authorizing>
</AuthorizeRouteView>
</Found>
<NotFound>
<LayoutView Layout="@typeof(MainLayout)">
<p>Access Denied</p>
</LayoutView>
</NotFound>
</Router>
</CascadingAuthenticationState>
</Error>
@code {
private List<System.Reflection.Assembly> lazyLoadedAssemblies = new List<System.Reflection.Assembly>();
private async Task OnNavigation(NavigationContext context)
{
if (context.Path == "" || context.Path == "settings") // Url of the page that needs the lazy loaded assembly
{
var assemblies = await AssemblyLoader.LoadAssembliesAsync(new[] { "MudBlazor.dll" });
lazyLoadedAssemblies.AddRange(assemblies);
}
}
}
- 이전글[Blazor WASM] 업데이트 Publish -> Client 업데이트 적용 21.12.28
- 다음글[SignalR] Automatically reconnect 21.12.27
댓글목록
등록된 댓글이 없습니다.