【问题标题】:Error: Could not find 'blazor_apexchart.renderChart' ('blazor_apexchart' was undefined)错误:找不到“blazor_apexchart.renderChart”(“blazor_apexchart”未定义)
【发布时间】:2022-01-18 23:24:06
【问题描述】:

我已经为 apexchart.js 使用了 blazor 包装器来构建图表组件。这是我的 ApexChart 剃须刀组件。

<BLChartContainer>

                @if (chartDetails!=null)
                {
                    <ApexChart @ref=_detailsChart TItem="LocationViseStockResponse"
                                    Title="Stocks"
                                    OnDataPointSelection=DataPointsSelected
                                    Debug>

                                <ApexPointSeries TItem="LocationViseStockResponse"
                                     Items="chartDetails"
                                     Name=""
                                     SeriesType="SeriesType.Bar"
                                     XValue="@(e => e.Location.CodeName)"
                                     YValue="@(e => e.Qty)"
                                     OrderByDescending="e=>e.X" />

                    </ApexChart>
                }

</BLChartContainer>

@code{

    private ApexChart<LocationViseStockResponse> _detailsChart;
    private SelectedData<LocationViseStockResponse> selectedData;
    private IList<LocationViseStockResponse> chartDetails;

   protected override async Task OnInitializedAsync()
   {
     _detailsChart = new();
      chartDetails= new List<LocationViseStockResponse>();
      //..
   }

   private void DataPointsSelected(SelectedData<LocationViseStockResponse> selectedData)
    {
        this.selectedData = selectedData;
        _detailsChart?.SetRerenderChart();
    }

}

但是当我运行应用程序时,我收到了这个控制台错误。

暴击:Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100] 未处理的异常渲染组件:找不到“blazor_apexchart.renderChart”(“blazor_apexchart”未定义)。 错误:找不到“blazor_apexchart.renderChart”(“blazor_apexchart”未定义)。 在 https://localhost:5050/_framework/blazor.webassembly.js:1:328 在 Array.forEach () 在 a.findFunction (https://localhost:5050/_framework/blazor.webassembly.js:1:296) 在 _ (https://localhost:5050/_framework/blazor.webassembly.js:1:2437) 在 https://localhost:5050/_framework/blazor.webassembly.js:1:3325 在新的承诺 () 在 Object.beginInvokeJSFromDotNet (https://localhost:5050/_framework/blazor.webassembly.js:1:3306) 在 Object.Rt [as invokeJSFromDotNet] (https://localhost:5050/_framework/blazor.webassembly.js:1:59738) 在 _mono_wasm_invoke_js_blazor (https://localhost:5050/_framework/dotnet.6.0.0.rbisnsgo77.js:1:193780) 在 wasm://wasm/00945abe:wasm-function[2588]:0x8065b

确切的问题是什么?请帮助我,感谢您的所有帮助

【问题讨论】:

    标签: blazor blazor-webassembly apexcharts blazor-jsinterop


    【解决方案1】:

    这可能是因为Blazor-ApexCharts 仅在您将@using ApexCharts; 放入_Imports.razor 而不是直接放入组件/页面时才有效。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-07-27
      • 2018-09-20
      • 1970-01-01
      • 1970-01-01
      • 2016-05-09
      • 1970-01-01
      • 2016-04-11
      • 2018-11-26
      相关资源
      最近更新 更多