简体   繁体   English

为什么 ChartJs.Blazor 有错误(更改 ASPNETCORE_ENVIRONMENT)

[英]Why is there an error in ChartJs.Blazor (change in ASPNETCORE_ENVIRONMENT)

I have installed a NugetPacket: ChartJs.Blazor (v1.1.0).我已经安装了 NugetPacket:ChartJs.Blazor (v1.1.0)。 In a _Host.cshtml file have added在 _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" />

When the ASPNETCORE_ENVIRONMENT is set to Development it works, but when ASPNETCORE_ENVIRONMENT is changed to Production app crashes and returns error:当 ASPNETCORE_ENVIRONMENT 设置为Development时,它可以工作,但是当 ASPNETCORE_ENVIRONMENT 更改为Production应用程序崩溃并返回错误:

 Microsoft.JSInterop.JSException: Could not find 'ChartJsInterop' in 'window'. Error: Could not find 'ChartJsInterop' in 'window'.

Why is there the error in the Production and not in the Development mode?为什么生产模式有错误,而开发模式没有? Any solution to this problem?这个问题有什么解决办法吗?

Are you sure you didn't add it inside an <environment> HTML tag?你确定你没有将它添加到<environment> HTML 标签中吗? Example:例子:

<environment exclude="Production">
   <script src="_content/ChartJs.Blazor/ChartJsBlazorInterop.js" type="text/javascript" language="javascript"></script>
</environment>

Reference: https://docs.microsoft.com/en-us/aspnet/core/mvc/views/tag-helpers/built-in/environment-tag-helper?view=aspnetcore-5.0参考: https://docs.microsoft.com/en-us/aspnet/core/mvc/views/tag-helpers/built-in/environment-tag-helper?view=aspnetcore-5.0

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何为控制台应用程序设置 ASPNETCORE_ENVIRONMENT? - How to set ASPNETCORE_ENVIRONMENT for console application? 在T4模板中获取ASPNETCORE_ENVIRONMENT? - Get ASPNETCORE_ENVIRONMENT in T4 Template? 创建新的ASPNETCORE_ENVIRONMENT进行开发 - Create new ASPNETCORE_ENVIRONMENT for Development 如何在运行时设置 ASPNETCORE_ENVIRONMENT 变量 - How to set ASPNETCORE_ENVIRONMENT variable at runtime 是否可以重命名 ASPNETCORE_ENVIRONMENT 变量? - Is it possible to rename ASPNETCORE_ENVIRONMENT variable? 在构建配置中设置aspnetcore_environment - Set aspnetcore_environment within build configuration 为什么在Azure上设置ASPNETCORE_ENVIRONMENT变量时需要发布我的project.json - Why do I need to publish my project.json when setting ASPNETCORE_ENVIRONMENT variable on Azure 为什么 Webservice 不使用来自 web.config 的变量 AS.NETCORE_ENVIRONMENT - Why Webservice doesn't use variable ASPNETCORE_ENVIRONMENT from web.config 如何在 AzureDevops 中为 Dockerfile 设置环境变量(ASPNETCORE_ENVIRONMENT)? - How to set environment variables (ASPNETCORE_ENVIRONMENT) in AzureDevops for Dockerfile? AS.NETCORE_ENVIRONMENT 不再覆盖 DO.NET_ENVIRONMENT? - ASPNETCORE_ENVIRONMENT no longer overrides DOTNET_ENVIRONMENT?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM