.cshtml 更改时,为什么刷新后页面不更新

编程入门 行业动态 更新时间:2024-10-27 19:15:22
本文介绍了.cshtml 更改时,为什么刷新后页面不更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试 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 更改时,为什么刷新后页面不更新

本文发布于:2023-11-13 21:56:06,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1585424.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:页面   cshtml

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!