声明:借鉴liningit 的BlazorWebassemblyMultiPagesTab的代码实现(https://github.com/liningit/BlazorWebassemblyMultiPagesTab.git)
*可单独将BlazorMultiPageLib项目下载到本地
dotnet new -int WebAssembly -o ProjectName
dotnet sln add "xx\xx\BlazorMultiPageLib.csproj"
+builder.Services.AddBlazoredLocalStorage();
+builder.Services.AddFluentUIComponents();
...
app.MapRazorComponents<App>()
.AddInteractiveWebAssemblyRenderMode()
.AddAdditionalAssemblies(typeof(BlazorApp.Client._Imports).Assembly)
+.AddAdditionalAssemblies(typeof(BlazorMultiPageLib._Imports).Assembly);
+builder.Services.AddBlazoredLocalStorageAsSingleton();
+builder.Services.AddFluentUIComponents();
(如果采用wasm模式,将Routers.razor文件放入Client项目根目录,否则会报xxx.Components.Routes' could not be found in the assembly 'xxx')
<Router AppAssembly="typeof(Program).Assembly" AdditionalAssemblies="new[] { typeof(Client._Imports).Assembly,typeof(BlazorMultiPageLib._Imports).Assembly }">
<Found Context="routeData">
<RouteView RouteData="routeData" DefaultLayout="typeof(BlazorMultiPageLib.Layout.MainLayout)" />
<FocusOnNavigate RouteData="routeData" Selector="h1" />
</Found>
</Router>
+<link href="_content/Microsoft.FluentUI.AspNetCore.Components/css/reboot.css" rel="stylesheet" />
+<link rel="stylesheet" href="_content/BlazorMultiPageLib/app.css" />
<Routes @rendermode="InteractiveWebAssembly" />
+<script src="_content/Microsoft.FluentUI.AspNetCore.Components/Microsoft.FluentUI.AspNetCore.Components.lib.module.js" type="module" async></script>