【发布时间】:2020-06-23 19:51:35
【问题描述】:
我最初有一个可用的Blazorise LineChart,它只是从上周提取公司的股价数据并将其放入一个简单的折线图中。
我想重构这个页面,将 LineChart 的代码拆分为带有 Partial Class 的 Razor 组件,以便我可以重用这个组件,添加其他类似的组件并清理我的代码。
按照 MSDN 文档 here 执行此操作(并且没有进行任何功能更改)之后,我在控制台中收到以下 JSRuntime 错误,因此 LineChart 不再显示:
以下是我的 Razor 组件的相关 sn-ps 代码 - 谁能给我一些建议,说明为什么会出现此错误?
Index.Razor
@page "/"
@using Stock_Market_Dashboard.Components
<LineChartComponentBase />
位于项目/组件中的以下文件:
_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
{
//...
【问题讨论】:
标签: .net asp.net-core .net-core blazor blazorise