我正在尝试 Blazor,但我不明白为什么在刷新浏览器页面后更改 component 时它没有更新?client 不应该像 angular 那样更新自己吗?
I am trying out Blazor and i do not understand why when changing a component after refreshing the browser page it does not update ? Shouldn't the client update itself similar to how angular does?
它仅在我重新启动 blazor 服务器时刷新.
It only refreshes when i restart the blazor server.
Index.cshtml
@page "/" <h1>Hello, world!</h1>如果我将 <h1> 中的文本更改为 Hello people ,我将保存项目并刷新页面(正如我在Blazor 教程)我不应该看到 Hello people 吗?
If i change lets say the text inside the <h1> to Hello people , i save the project and i refresh the page ( as i am advised in the Blazor tutorial) shouldn't i see Hello people ?
推荐答案在 Asp Core 3.0 之后,使用 Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation 包启用运行时编译.要启用运行时编译,应用必须:
After Asp Core 3.0, Runtime compilation is enabled using the Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation package. To enable runtime compilation, apps must:
安装 Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation NuGet 包.
Install the Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation NuGet package.
更新项目的 Startup.ConfigureServices 方法以包含对 AddRazorRuntimeCompilation 的调用:
Update the project's Startup.ConfigureServices method to include a call to AddRazorRuntimeCompilation:
services .AddControllersWithViews() .AddRazorRuntimeCompilation();或
services.AddMvc().AddRazorRuntimeCompilation();更多推荐
.cshtml 更改时,为什么刷新后页面不更新
发布评论