当我从";ASPNETCORE_环境":"发展";至";ASPNETCORE_环境":"分段;有些脚本停止工作,比如找不到它们,例如:
Microsoft.AspNetCore.Components.Web.ErrorBoundary:警告:未处理的异常呈现组件:无法获取动态导入的模块:https://localhost:44303/_content/BlazorPro.BlazorSize/blazorSizeMediaModule.jsTypeError:无法获取动态导入的模块:https://localhost:44303/_content/BlazorPro.BlazorSize/blazorSizeMediaModule.js
Microsoft.JSInterop.JSException:无法获取动态导入的模块:https://localhost:44303/_content/BlazorPro.BlazorSize/blazorSizeMediaModule.jsTypeError:无法获取动态导入的模块:https://localhost:44303/_content/BlazorPro.BlazorSize/blazorSizeMediaModule.js位于Microsoft.JSInterop.JSRuntime.IInvokeAsync[TValue](Int64 targetInstanceId,String identifier,Object[]args(位于BlazorPro。BlazorSize.MediaQueryService.CreateMediaQueryList(DotNetObjectReference`1 DotNetObjectReference(位于BlazorPro。BlazorSize.MediaQueryList.OnAfterRenderAsync(布尔firstRender(在Microsoft.AspNetCore.Components.RenderTree.RRenderer.GetErrorHandledTask(任务任务到句柄,ComponentState owningComponentState(
知道为什么会发生这种行为吗?
答案如下:https://github.com/EdCharbeneau/BlazorSize/issues/71
基本上,我必须在网络主机中启用静态网络资产:
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder => {
webBuilder.UseStaticWebAssets(); // <----
webBuilder.UseStartup<Startup>();
});