c# - 在 MVC 下实现的 Blazor 组件未呈现
问题描述
使用 .NET Core 和最新版本的服务器端 Blazor,我在现有 MVC 应用程序中实现了 Blazor 组件(感谢 Chris https://chrissinty.com/using-blazor-components-in-an-existing-mvc-application / ) 我只能在默认页面(即https://localhost:5433)上呈现 Blazor 组件。Blazor 组件在默认页面中运行良好,但是当我尝试使用https://localhost:5433/home/index或任何其他视图打开视图时,Blazor 组件不会被呈现。
我在这里错过了什么吗?
解决方案
我想到了!回答一些问题和一个可重复的例子:
创建一个空的 MVC 核心应用程序并按照 Chrissianity 的教程了解如何将 Blazor 实施到现有 MVC https://chrissinty.com/using-blazor-components-in-an-existing-mvc-application/
我没有注意到我正在使用
@(await Html.RenderComponentAsync<CoursesList>(**RenderMode.Server**,
new { Courses = Model }))
而不是
@(await Html.RenderComponentAsync<CoursesList(**RenderMode.ServerPrerendered**,
new { Courses = Model }))
当我更改渲染模式时,页面现在可以工作了。
推荐阅读
- angular - 如何使用猫鼬快递和角度从数组中删除特定对象
- vb.net - 如何在水晶报表的详细信息部分底部放置一条水平线
- html - 即使遵循模板,图像映射也不起作用
- excel - 如何根据另一个单元格中的文本对一个字母对应一个值的行求和?
- cassandra - 非主键列的 Cassandra IN 子句
- c# - 如何将列表类型对象的列名与 C# 中的字符串进行比较
- python - 如何根据列表元素限制加减法?
- angular - Angular 应用程序构建管道 - VSTS 中的持续集成
- reactjs - 如何从效果外部使用 React Hooks 设置状态?
- gembox-document - 使用 Gembox Document 合并图片大小