{ "cells": [ { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "# 使用 Blazor 进行交互式展示" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "在笔记本中使用Blazor:原生的没找到介绍和使用方法。但找到一大侠开发的扩展库-[BlazorInteractive](https://github.com/plbonneville/BlazorInteractive),使用前只要引入此nuget包即可。\n", "\n", "特别注意:此方法在.net 8中使用,**.net 9+中异常**(.NET 9 移除了执行JS相关的 Microsoft.JSInterop.IJSUnmarshalledRuntime);\n", "\n", "> 目前,没有找到解决方案。已经向BlazorInteractive库提交了问题,但该库已年久失修(停止在.net 8),不知道能不能解决及发布适用.net 9的新版。" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "## 添加 Nuget 包" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "dotnet_interactive": { "language": "csharp" }, "polyglot_notebook": { "kernelName": "csharp" } }, "outputs": [ { "data": { "text/html": [ "
This extension adds a new kernel that can render Blazor markdown.
\n", "\n", "\n",
" \n",
"#!blazor\n",
"Counter
\n",
"\n",
"\n",
" Current count: @currentCount\n",
"
\n",
"\n",
"@code {\n",
" int currentCount = 0;\n",
"}
\n",
"
\n",
"\n",
" This extension also adds the compiled component as a type to the interactive workspace.
\n", "\n", "Options:
\n", "__Main