svg - 如何配置在 sveltekit 中使用 svg 文件?

在sveltekit中导入和使用svg文件我引用了这篇文章 https://riez.medium.com/svelte-kit-importing-svg-as-svelte-component-781903fef4ae 顺便说一句,当我最后输入代码时

<svelte:component this={Logo} />

我得到如下错误

<svelte:component this={...}> is not a valid SSR component. You may need to review your build config to ensure that dependencies are compiled, rather than imported as pre-compiled modules

我希望有人能帮我解决这个问题。

最佳答案

有一个用于内联 SVG:s 的 SvelteKit 插件。您可以通过三种不同的方式使用该插件:

  1. 作为 Svelte 组件
  2. 作为 URL(例如用于 img 标签)
  3. 作为原始文本(例如用于 {@html rawText})

https://www.npmjs.com/package/@poppanator/sveltekit-svg

https://stackoverflow.com/questions/67337435/

相关文章:

powerbi - Multi-Tenancy 场景下如何访问power BI Service

python - PyCharm 看不到项目中的文件

GitHub - 当非默认分支与 main 合并时,PR 链接问题不会关闭

matlab - 如何使用 matlab 正确绘制矢量线性方程?

flutter - 为什么 SliverFillRemaining 膨胀得太多了?

c++ - 使用具有非 constexpr 值的 int 模板函数

python - 仅当 "Lossless"时才转换为整数?

javascript - 选择选项后如何取消突出显示选择元素?

r - 将字符串拆分为单词并分配给新列

http - 使用 Clack/ningle 在 Web 服务器中嵌入图像