在我的剃须刀组件项目中,我向解决方案中添加了blazor组件库。我可以从我的.app项目中调用组件库中的组件,但是.css和其他文件似乎无法从blazor组件库中加载。 我查看了组件库.scproj文件,但无法弄清缺少的内容:
<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>
答案 0 :(得分:1)
这是当前Razor Components版本的限制。它无法从组件库导入静态资产。解决方法是,您应手动复制它们,直到在下一版本中对其进行修复。
答案 1 :(得分:0)
静态资产自预览版6开始就可以使用。请在以下位置阅读有关此主题的博客文章:https://devblogs.microsoft.com/aspnet/asp-net-core-and-blazor-updates-in-net-core-3-0-preview-6/