【发布时间】:2021-03-19 05:28:06
【问题描述】:
我已经安装了 NugetPacket:ChartJs.Blazor (v1.1.0)。在 _Host.cshtml 文件中添加了
<script src="_content/ChartJs.Blazor/moment-with-locales.min.js" type="text/javascript" language="javascript"></script>
<!-- Reference the included ChartJs javascript file. -->
<script src="_content/ChartJs.Blazor/Chart.min.js" type="text/javascript" language="javascript"></script>
<!-- This is the glue between the C# code and the ChartJs charts -->
<script src="_content/ChartJs.Blazor/ChartJsBlazorInterop.js" type="text/javascript" language="javascript"></script>
<!-- Some styling -->
<link rel="stylesheet" href="_content/ChartJs.Blazor/ChartJSBlazor.css" />
当 ASPNETCORE_ENVIRONMENT 设置为 Development 时,它可以工作,但是当 ASPNETCORE_ENVIRONMENT 更改为 Production 时,应用程序崩溃并返回错误:
Microsoft.JSInterop.JSException: Could not find 'ChartJsInterop' in 'window'.
Error: Could not find 'ChartJsInterop' in 'window'.
为什么在生产模式中出现错误,而不是在开发模式中?这个问题有什么解决办法吗?
【问题讨论】: