Blazor 组件库中的 CSS 未加载

ali*_*nli 5 blazor-server-side

在我的 razor 组件项目中,我向解决方案添加了 blazor 组件库。我可以从 .app 项目中调用组件库中的组件,但 .css 和其他文件似乎不会从 Blazor 组件库加载。我查看了组件库 .csproj 文件,但我无法弄清楚缺少什么:

<Project Sdk="Microsoft.NET.Sdk.Razor">

    <PropertyGroup>
        <TargetFramework>netstandard2.0</TargetFramework>
        <IsPackable>true</IsPackable>
        <LangVersion>7.3</LangVersion>
    </PropertyGroup>

    <ItemGroup>
        <!-- .js/.css files will be referenced via <script>/<link> tags; other content files will just be included in the app's 'dist' directory without any tags referencing them -->
        <EmbeddedResource Include="content\**\*.js" LogicalName="blazor:js:%(RecursiveDir)%(Filename)%(Extension)" />
        <EmbeddedResource Include="content\**\*.css" LogicalName="blazor:css:%(RecursiveDir)%(Filename)%(Extension)" />
        <EmbeddedResource Include="content\**" Exclude="**\*.js;**\*.css" LogicalName="blazor:file:%(RecursiveDir)%(Filename)%(Extension)" />    
    </ItemGroup>

    <ItemGroup>
        <PackageReference Include="Microsoft.AspNetCore.Components.Browser" Version="3.0.0-preview-19075-0444" />
        <PackageReference Include="Microsoft.AspNetCore.Components.Build" Version="3.0.0-preview-19075-0444" PrivateAssets="all" />
    </ItemGroup>

</Project>
Run Code Online (Sandbox Code Playgroud)

小智 2

这是当前版本的 Razor Components 的限制。它无法从组件库导入静态资源。作为解决方法,您应该手动复制它们,直到在下一个版本中修复为止。