应用程序启动时 Blazor css 文件不更新

Kre*_*lex 6 css blazor blazor-webassembly

然而,我将一些自定义 CSS 从 bootstraps 网站添加到 Blazor 中的 app.css 文件中,同时在 Visual Studio 中编辑并保存该文件。当应用程序启动并加载 app.css 时,它会加载旧版本的 app.css 而无需我进行更改。有人知道为什么会发生这种情况吗?提前致谢

编辑后的 ​​CSS 文件

// ... some more css above....

.b-example-divider {
    height: 3rem;
    background-color: rgba(0, 0, 0, .1);
    border: solid rgba(0, 0, 0, .15);
    border-width: 1px 0;
    box-shadow: inset 0 0.5em 1.5em rgb(0 0 0 / 10%), inset 0 0.125em 0.5em rgb(0 0 0 / 15%);
}

#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}
#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}
Run Code Online (Sandbox Code Playgroud)

应用程序加载app.css

丢失.b-example-divider并仅加载更改前的文档 在此输入图像描述

Isa*_*aac 18

如果您没有看到已应用于 app.css 文件的更改,则可能需要手动清除浏览器缓存。

更好的解决方案是使用版本控制,如下所示:

<link rel="stylesheet" type="text/css" href="css/app.css?version=0.1">
Run Code Online (Sandbox Code Playgroud)

添加版本号作为查询参数。这将迫使浏览器寻找最新版本的样式表......