[英]Is it possible to load blazor pages (not components) from RCL without changing App.razor?
I am trying to create an blazor assembly that should be installed as a nuget package.我正在尝试创建一个应该作为 nuget 包安装的 blazor 程序集。 The idea is to load the blazor pages as if they where on an endpoint route, and this should be done by extension methods on startup.cs (net5)/ program.cs (net6) only.
这个想法是加载 blazor 页面,就好像它们在端点路由上一样,这应该仅通过 startup.cs (net5)/program.cs (net6) 上的扩展方法来完成。
The regular solution is to add AdditionalAssemblies on Router component inside App.razor.常规解决方案是在 App.razor 内的 Router 组件上添加 AdditionalAssemblies。
<Router
AppAssembly="typeof(Program).Assembly"
AdditionalAssemblies="new[] { typeof(Component1).Assembly }">
...
</Router>
Is there a way to achieve the same from an extension method called by startup.cs or program.cs?有没有办法通过 startup.cs 或 program.cs 调用的扩展方法实现相同的功能?
Check my repo, shows different ways to load RCL to a project, the only limitation today is to register dynamically a DI from the component library检查我的仓库,显示将 RCL 加载到项目的不同方法,今天唯一的限制是从组件库中动态注册 DI
https://github.com/elgransan/BlazorPluginComponents https://github.com/elgransan/BlazorPluginComponents
I added an example for loading a RCL as a Page dynamically我添加了一个将 RCL 作为页面动态加载的示例
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.