我最初有一个可用的Blazorise LineChart,它只是从上周提取公司的股价数据并将其放入一个简单的折线图中。
我想重构此页面以将 LineChart 的代码拆分为带有部分类的 Razor 组件,以允许我重用此组件、添加其他类似组件并清理我的代码。
在按照此处的 MSDN 文档执行此操作(并且没有进行任何功能更改)之后,我在控制台中收到以下 JSRuntime 错误,因此 LineChart 不再显示:
以下是我的 Razor 组件的相关代码片段 - 谁能给我一些建议,说明为什么会显示此错误?
索引.剃刀
@page "/"
@using Stock_Market_Dashboard.Components
<LineChartComponentBase />
以下文件位于Project/Components中:
_Imports.Razor
@using Microsoft.AspNetCore.Components
@using Blazorise
@using Blazorise.Charts
LineChartComponent.razor
@inherits LineChartComponentBase
<Card>
<CardHeader>Settings</CardHeader>
<CardBody>
<Paragraph Visibility="Visibility.Always" Style="display:flex;flex-direction:row;margin:auto;">
<Switch Style="padding-right: 20px;" TValue="bool" Checked="@amazon" CheckedChanged="@OnAmazonChanged">Amazon</Switch>
<Switch Style="padding-right: 20px;" TValue="bool" Checked="@apple" CheckedChanged="@OnAppleChanged">Apple</Switch>
<Switch TValue="bool" Checked="@google" CheckedChanged="@OnGoogleChanged">Google</Switch>
<Button Style="margin-left:20px;padding:0;font-weight:bolder;" Clicked="@(async () => await HandleRedraw(lineChart))">Refresh</Button>
</Paragraph>
</CardBody>
</Card>
<LineChart @ref="lineChart" TItem="DataPoint" OptionsObject="@lineChartOptions" />
LineChartComponent.cs
using Microsoft.AspNetCore.Components;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Stock_Market_Dashboard.Data;
using Extensions;
using Blazorise.Charts;
namespace Stock_Market_Dashboard.Components
{
public partial class LineChartComponentBase : ComponentBase
{
//...