简体   繁体   中英

Why Blazor style isolation not working with routing?

When a component is opened by navigating to its route, style isolation does not work, the styles are not applied, but if you add this component to another, then the styles work. I can't understand if this is a feature of the framework or my mistake

When a component is opened by navigating to its route, it's already a component within another component, so it will work exactly the same as your second case. So I think the answer is "my mistake".

As you've provided no code, here's a very simple demo page showing it working in a routed component.

Test.razor

@page "/"
<h3 class="makemered">Test</h3>
@code {
}

Test.razor.css

.makemered {
    background-color: red;
    color: white;
}

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM